-- 检修工单新增字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FCARDTITLE') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FCARDTITLE NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FRISKCARD') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FRISKCARD CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FISPRIORITY') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FISPRIORITY CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FISLADDER') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FISLADDER CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FISMAJORWORK') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FISMAJORWORK CHAR(1) DEFAULT '0' NOT NULL );
 

 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROMULZONE') 
 CREATE TABLE T_POM_MROMULZONE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
 EXEC P_ALTERPK 'PK_POM_MROMULZONE', 'T_POM_MROMULZONE', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_POM_MROMULZONE_FK') CREATE INDEX IDX_POM_MROMULZONE_FK ON T_POM_MROMULZONE ( FENTRYID );


 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROMULAREA') 
 CREATE TABLE T_POM_MROMULAREA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
 EXEC P_ALTERPK 'PK_POM_MROMULAREA', 'T_POM_MROMULAREA', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_POM_MROMULAREA_FK') CREATE INDEX IDX_POM_MROMULAREA_FK ON T_POM_MROMULAREA ( FENTRYID );
 
 --工卡标题修改长度 
 EXEC P_ALTERCOLUMN 'T_POM_MROORDERENTRY', 'FCARDTITLE', 'NVARCHAR(2000)', 'NOT NULL', '0100', ''' '''; 
 
 