/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ROLLCONFIG') 
 CREATE TABLE T_EB_ROLLCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FENABLE NVARCHAR(10) DEFAULT ' ' NOT NULL,
FMASTERID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FSTARTDATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FROLLVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FACTVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBASISTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINITSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ROLLTEMPLATE') 
 CREATE TABLE T_EB_ROLLTEMPLATE (
FPKID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ROLLINIT') 
 CREATE TABLE T_EB_ROLLINIT (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXECUTEDATE DATETIME,
FEXECUTESTATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXECUTOR NVARCHAR(50) DEFAULT ' ' NOT NULL,
FROLLCONFIG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRGAUDITTRIAL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCAUDITTRIAL NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ROLLCONFIG_L') 
 CREATE TABLE T_EB_ROLLCONFIG_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


 --- drop column --------- 不允许删除表T_EB_INTEGRATION_MAPDIM的字段FNEEDMEMBER，请恢复pdm中的字段 ------------------- 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BIZRULETEMPLATEDIS' AND KSQL_COL_NAME ='FEXECSEQ') 
 ALTER TABLE T_EB_BIZRULETEMPLATEDIS ADD (FEXECSEQ INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_USERSELECT' AND KSQL_COL_NAME ='FDATEALTER') 
 ALTER TABLE T_EB_USERSELECT ADD (FDATEALTER DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VIEWMEMBER' AND KSQL_COL_NAME ='FMODIFIER') 
 ALTER TABLE T_EB_VIEWMEMBER ADD (FMODIFIER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VIEWMEMBER' AND KSQL_COL_NAME ='FMODIFYDATE') 
 ALTER TABLE T_EB_VIEWMEMBER ADD (FMODIFYDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_REPORTQUERY' AND KSQL_COL_NAME ='FDATASETID') 
 ALTER TABLE T_EB_REPORTQUERY ADD (FDATASETID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_REPORTSHARE' AND KSQL_COL_NAME ='FDATASETID') 
 ALTER TABLE T_EB_REPORTSHARE ADD (FDATASETID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME ='FVIEWID') 
 ALTER TABLE T_EB_STRUCTOFCHANGETYPE ADD (FVIEWID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME ='FFORMULA') 
 ALTER TABLE T_EB_STRUCTOFCHANGETYPE ADD (FFORMULA NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME ='FFORMULANAME') 
 ALTER TABLE T_EB_STRUCTOFCHANGETYPE ADD (FFORMULANAME NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_INTEGRATION_LOG') 
 CREATE TABLE T_EB_INTEGRATION_LOG (
FID BIGINT DEFAULT 0 NOT NULL,
FINTEGRATIONID BIGINT DEFAULT 0 NOT NULL,
FISYNCCOUNT INT DEFAULT 0 NOT NULL,
FSUCCESSCOUNT INT DEFAULT 0 NOT NULL,
FFAILCOUNT INT DEFAULT 0 NOT NULL,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL,
FCREATEDATEFIELD DATETIME,
FMODIFYDATEFIELD DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_INTEGRATION_LOGDET') 
 CREATE TABLE T_EB_INTEGRATION_LOGDET (
FID BIGINT DEFAULT 0 NOT NULL,
FLOGID BIGINT DEFAULT 0 NOT NULL,
FFAILMSG NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDATAJSON NCLOB,
FINTEGRATIONID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATEFIELD DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_INTEGRATION' AND KSQL_COL_NAME ='FMETRICTYPE') 
 ALTER TABLE T_EB_INTEGRATION ADD (FMETRICTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_INTEGRATION' AND KSQL_COL_NAME ='FSRCSINGLEMETRIC') 
 ALTER TABLE T_EB_INTEGRATION ADD (FSRCSINGLEMETRIC NVARCHAR(50) DEFAULT ' ' NOT NULL );

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