-- 生产组织属性定义
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FMM_DEFAULTORG' AND KSQL_COL_NAME ='FNAME')
ALTER TABLE T_FMM_DEFAULTORG ADD (FNAME  VARCHAR(100) DEFAULT ' ' NOT NULL);

-- 工艺模式
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FMM_PROMODEDEFINE' AND KSQL_COL_NAME ='FNAME')
ALTER TABLE T_FMM_PROMODEDEFINE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL);

-- ECN版本
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_ECNVERSION' AND KSQL_COL_NAME ='FNAME')
ALTER TABLE T_PDM_ECNVERSION ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL);

-- BOM维护
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_MFTBOM' AND KSQL_COL_NAME ='FNAME')
ALTER TABLE T_PDM_MFTBOM ADD (FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_MFTBOM' AND KSQL_COL_NAME ='FDESCRIPTION')
ALTER TABLE T_PDM_MFTBOM ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL);
-- BOM维护：联副产品-备注
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_MFTBOMCOPENTRY' AND KSQL_COL_NAME ='FREMARK')
ALTER TABLE T_PDM_MFTBOMCOPENTRY ADD (FREMARK   NVARCHAR(255) DEFAULT ' ' NOT NULL);
-- BOM维护：组件-备注
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_MFTBOMENTRY' AND KSQL_COL_NAME ='FREMARK')
ALTER TABLE T_PDM_MFTBOMENTRY ADD (FREMARK   NVARCHAR(255) DEFAULT ' ' NOT NULL);
-- BOM维护：安装位置-安装位置、备注
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_MFTBOMSETUPENTRY' AND KSQL_COL_NAME ='FSETUPLOCATION')
ALTER TABLE T_PDM_MFTBOMSETUPENTRY ADD (FSETUPLOCATION NVARCHAR(2000) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_MFTBOMSETUPENTRY' AND KSQL_COL_NAME ='FREMARK')
ALTER TABLE T_PDM_MFTBOMSETUPENTRY ADD (FREMARK NVARCHAR(100) DEFAULT ' ' NOT NULL);

-- 工艺路线维护
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_ROUTE' AND KSQL_COL_NAME ='FNAME')
ALTER TABLE T_PDM_ROUTE ADD (FNAME VARCHAR(100) DEFAULT ' ' NOT NULL);

-- 生产版本
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PDM_MANUVERSION' AND KSQL_COL_NAME ='FNAME')
ALTER TABLE T_PDM_MANUVERSION ADD (FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL);