IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_TASK' AND KSQL_COL_NAME ='FISSPECIAL')
 ALTER TABLE T_PMTS_TASK ADD (FISSPECIAL CHAR(1) DEFAULT '0' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_TASK' AND KSQL_COL_NAME ='FIMPORTANTTASK')
 ALTER TABLE T_PMTS_TASK ADD (FIMPORTANTTASK CHAR(1) DEFAULT '0' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_WBS' AND KSQL_COL_NAME ='FSOURCEPLANTYPEID')
 ALTER TABLE T_PMTS_WBS ADD ( FSOURCEPLANTYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_WBS' AND KSQL_COL_NAME ='FSOURCEID')
 ALTER TABLE T_PMTS_WBS ADD ( FSOURCEID BIGINT DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_TASK' AND KSQL_COL_NAME ='FSOURCEPLANTYPEID')
 ALTER TABLE T_PMTS_TASK ADD ( FSOURCEPLANTYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_TASK' AND KSQL_COL_NAME ='FSOURCEID')
 ALTER TABLE T_PMTS_TASK ADD ( FSOURCEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMPD_PROJECT_MCC' AND KSQL_COL_NAME ='FEXEPKGID')
 ALTER TABLE T_PMPD_PROJECT_MCC ADD ( FEXEPKGID BIGINT DEFAULT 0 NOT NULL );

 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROJECTPLANCONF')
 CREATE TABLE T_FMM_PROJECTPLANCONF (
	FID               BIGINT          DEFAULT 0     NOT NULL,       
	FNUMBER           NVARCHAR(30)    DEFAULT ' '   NOT NULL,        
	FCREATEORGID      BIGINT          DEFAULT 0     NOT NULL,       
	FORGID            BIGINT          DEFAULT 0     NOT NULL,       
	FCTRLSTRATEGY     NVARCHAR(50)    DEFAULT ' '   NOT NULL,       
	FSYNCOBJ          NVARCHAR(50)    DEFAULT ' '   NOT NULL,      
	FREMARK           NVARCHAR(255)   DEFAULT ' '   NOT NULL,       
	FNAME             NVARCHAR(50)    DEFAULT ' '   NOT NULL,        
	FSTATUS           NVARCHAR(50)    DEFAULT ' '   NOT NULL,       
	FCREATORID        BIGINT          DEFAULT 0     NOT NULL,       
	FMODIFIERID       BIGINT          DEFAULT 0     NOT NULL,        
	FENABLE           NVARCHAR(50)    DEFAULT ' '   NOT NULL,       
	FCREATETIME       DATETIME,     
	FMODIFYTIME       DATETIME,       
	FMASTERID         BIGINT          DEFAULT 0     NOT NULL,      
	FPROJECTID        BIGINT          DEFAULT 0     NOT NULL,        
	FAUDITORID        BIGINT          DEFAULT 0     NOT NULL,      
	FAUDITTIME        DATETIME       
);

 EXEC P_ALTERPK 'PK_FMM_PROJECTPLANCONF', 'T_FMM_PROJECTPLANCONF', 'FID', '1';
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FMM_PROJECTPLANCONF_FNUM') CREATE INDEX IDX_FMM_PROJECTPLANCONF_FNUM ON T_FMM_PROJECTPLANCONF ( FNUMBER );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MM_PROJECTPLANCONF_FCD') CREATE INDEX IDX_MM_PROJECTPLANCONF_FCD ON T_FMM_PROJECTPLANCONF ( FCREATEORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MM_PROJECTPLANCONF_FCT') CREATE INDEX IDX_MM_PROJECTPLANCONF_FCT ON T_FMM_PROJECTPLANCONF ( FCREATETIME );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROJECTPLANCONF_L')
 CREATE TABLE T_FMM_PROJECTPLANCONF_L (
	FPKID             NVARCHAR(36)    DEFAULT ' '   NOT NULL,        
	FID               BIGINT          DEFAULT 0     NOT NULL,        
	FLOCALEID         NVARCHAR(10)    DEFAULT ' '   NOT NULL,       
	FNAME             NVARCHAR(50)    DEFAULT ' '   NOT NULL   
);

 EXEC P_ALTERPK 'PK_FMM_PROJECTPLANCONF_L', 'T_FMM_PROJECTPLANCONF_L', 'FPKID', '1';
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FMM_PROJECTPLANCONF_L') CREATE INDEX IDX_FMM_PROJECTPLANCONF_L ON T_FMM_PROJECTPLANCONF_L ( FID ,FLOCALEID );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROJECTPLANSTRA')
 CREATE TABLE T_FMM_PROJECTPLANSTRA (
	FENTRYID           BIGINT         DEFAULT 0     NOT NULL,       
	FID                BIGINT         DEFAULT 0     NOT NULL,       
	FSEQ               INT            DEFAULT 0     NOT NULL,        
	FSOURCEPLANTYPEID  BIGINT         DEFAULT 0     NOT NULL,       
	FSOURCEPLANTYPE1   BIGINT         DEFAULT 0     NOT NULL,        
	FENEW              CHAR(1)        DEFAULT '0'   NOT NULL,       
	FEEDIT             CHAR(1)        DEFAULT '0'   NOT NULL,        
	FEDELETE           CHAR(1)        DEFAULT '0'   NOT NULL,      
	FCOMBOFIELD        NVARCHAR(50)   DEFAULT ' '   NOT NULL,       
	FREMARK            NVARCHAR(255)  DEFAULT ' '   NOT NULL      
);

 EXEC P_ALTERPK 'PK_FMM_PROJECTPLANSTRA', 'T_FMM_PROJECTPLANSTRA', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FMM_PROJECTPLANSTRA_FSEQ') CREATE INDEX IDX_FMM_PROJECTPLANSTRA_FSEQ ON T_FMM_PROJECTPLANSTRA ( FID ,FSEQ );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FMM_STANDARDTASK_TYPE_FID') CREATE INDEX IDX_FMM_STANDARDTASK_TYPE_FID ON T_FMM_STANDARDTASK_TYPE ( FID );



