-- 协同计划单增加字段：供应规则、供货组织、供货仓库、供货仓位
-- 供应规则
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FSUPPLYRULE')
ALTER TABLE T_MRP_RATIVEORDER ADD (FSUPPLYRULE VARCHAR(50) NOT NULL DEFAULT ' ');

-- 供货组织
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FSUPPLYORGUNITID')
ALTER TABLE T_MRP_RATIVEORDER ADD (FSUPPLYORGUNITID BIGINT NOT NULL DEFAULT 0);

-- 供货仓库
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FSUPPLYWAREHOUSEID')
ALTER TABLE T_MRP_RATIVEORDER ADD (FSUPPLYWAREHOUSEID BIGINT NOT NULL DEFAULT 0);

-- 供货仓位
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FSUPPLYLOCATIONID')
ALTER TABLE T_MRP_RATIVEORDER ADD (FSUPPLYLOCATIONID BIGINT NOT NULL DEFAULT 0);

-- 模拟协同计划单继承了协同计划单，需要同步加字段
-- 供应规则
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FSUPPLYRULE')
ALTER TABLE T_MRP_SIMCOLORDER ADD (FSUPPLYRULE VARCHAR(50) NOT NULL DEFAULT ' ');

-- 供货组织
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FSUPPLYORGUNITID')
ALTER TABLE T_MRP_SIMCOLORDER ADD (FSUPPLYORGUNITID BIGINT NOT NULL DEFAULT 0);

-- 供货仓库
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FSUPPLYWAREHOUSEID')
ALTER TABLE T_MRP_SIMCOLORDER ADD (FSUPPLYWAREHOUSEID BIGINT NOT NULL DEFAULT 0);

-- 供货仓位
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FSUPPLYLOCATIONID')
ALTER TABLE T_MRP_SIMCOLORDER ADD (FSUPPLYLOCATIONID BIGINT NOT NULL DEFAULT 0);