/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SYS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_WARN_EARLYWARN') 
 CREATE TABLE T_WARN_EARLYWARN (
FID VARCHAR(36) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FDATASOURCETYPE VARCHAR(10) DEFAULT 'Custom' NOT NULL,
FDATASOURCEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCONDITIONFORMID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENABLED CHAR(1) DEFAULT '1' NOT NULL,
FLEAF CHAR(1) DEFAULT '1' NOT NULL,
FISV VARCHAR(10) DEFAULT ' ' NOT NULL,
FMASTERID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPARENTID VARCHAR(36) DEFAULT ' ' NOT NULL,
FINHERITPATH VARCHAR(300) DEFAULT ' ' NOT NULL,
FDATA NCLOB,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL,
FISTEMPLATE CHAR(1) DEFAULT '0' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME DEFAULT GETDATE() NOT NULL,
FMODIFYDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODELTYPE VARCHAR(30) DEFAULT 'EarlyWarnModel' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_WARN_EARLYWARN_L') 
 CREATE TABLE T_WARN_EARLYWARN_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID VARCHAR(36) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDATA NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_WARN_SCHEDULE_L') 
 CREATE TABLE T_WARN_SCHEDULE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID VARCHAR(36) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDATA NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_WARN_MONITOR_DETAILLOG') 
 CREATE TABLE T_WARN_MONITOR_DETAILLOG (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 1 NOT NULL,
FACTION VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
FRESULT NCLOB,
FRESULT_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_WARN_MONITORLOG') 
 CREATE TABLE T_WARN_MONITORLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FWARNSCHEDULEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FEARLYWARNID VARCHAR(36) DEFAULT ' ' NOT NULL,
FOPERATIONTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FSTARTTIME DATETIME DEFAULT GETDATE() NOT NULL,
FENDTIME DATETIME,
FEXECUTIONMILLIS BIGINT DEFAULT 0 NOT NULL,
FEXECUTIONTIME VARCHAR(50) DEFAULT ' ' NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL,
FCOMMENT NVARCHAR(200)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_WARN_SCHEDULE') 
 CREATE TABLE T_WARN_SCHEDULE (
FID VARCHAR(36) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FEARLYWARNID VARCHAR(36) DEFAULT ' ' NOT NULL,
FMONITORRANGE VARCHAR(50) DEFAULT ' ' NOT NULL,
FMONITORFREQUENCY VARCHAR(200) DEFAULT ' ' NOT NULL,
FJOBID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPLANID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPLANNUMBER VARCHAR(80) DEFAULT ' ',
FSTARTDATE DATETIME DEFAULT GETDATE() NOT NULL,
FENDDATE DATETIME,
FENABLE CHAR(1) DEFAULT '0' NOT NULL,
FDATA NCLOB,
FLASTSYNCTIME DATETIME,
FMODELTYPE VARCHAR(30) DEFAULT 'WarnScheduleModel' NOT NULL,
FMASTERID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPARENTID VARCHAR(36) DEFAULT ' ' NOT NULL,
FINHERITPATH VARCHAR(300) DEFAULT ' ' NOT NULL,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME DEFAULT GETDATE() NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FISTEMPLATE CHAR(1) DEFAULT '0' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FISV VARCHAR(10) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BAS_PICTURERESOURCE' AND KSQL_COL_NAME ='FISV') 
 ALTER TABLE T_BAS_PICTURERESOURCE ADD (FISV VARCHAR(8) DEFAULT ' ' NOT NULL );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SYS_table.sql **/
