/**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_ANALYZESCHEMECOLS') 
 CREATE TABLE T_EB_ANALYZESCHEMECOLS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 1 NOT NULL,
FCOLTYPE CHAR(1) DEFAULT '1' NOT NULL,
FISCOLHIDDEN CHAR(1) DEFAULT '1' NOT NULL,
FCOLNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOLCONFIGJSON NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DIFFANALYZESCHEME') 
 CREATE TABLE T_EB_DIFFANALYZESCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDATASETID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_MEMBERMAPPING' AND KSQL_COL_NAME ='FBUDIMMEMBERID') 
 ALTER TABLE T_EB_MEMBERMAPPING ADD (FBUDIMMEMBERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_MEMBERMAPPING' AND KSQL_COL_NAME ='FBUDIMMEMNAME') 
 ALTER TABLE T_EB_MEMBERMAPPING ADD (FBUDIMMEMNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_MEMBERMAPPING' AND KSQL_COL_NAME ='FBUDIMMEMNUMBER') 
 ALTER TABLE T_EB_MEMBERMAPPING ADD (FBUDIMMEMNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_MEMBERMAPPING' AND KSQL_COL_NAME ='FISCONTAIN') 
 ALTER TABLE T_EB_MEMBERMAPPING ADD (FISCONTAIN CHAR(1) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_EB_CURRENCYCONVERTLOG', 'FCONVERTRANGE', 'NCLOB', 'NULL', '1111', 'NULL';

 EXEC p_AlterColumn 'T_EB_REPORTATTACHMENT', 'FREMARK', 'NCLOB', 'NULL', '1111', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIMMEMBERRELATION' AND KSQL_COL_NAME ='FCUSTOMDIMNUMBER1') 
 ALTER TABLE T_EB_DIMMEMBERRELATION ADD (FCUSTOMDIMNUMBER1 NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_STRUCTOFENT' AND KSQL_COL_NAME ='FMEMBERSOURCE') 
 ALTER TABLE T_EB_STRUCTOFENT ADD (FMEMBERSOURCE CHAR(1) DEFAULT '0' NOT NULL );
 

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