/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISFORMULASETTING') 
 CREATE TABLE T_BCM_ISFORMULASETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FINCLUDEPOSTED CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDELEAF CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDELEAFACCOUNT CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDESUB CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDESUBACCOUNT CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDEALLASSISTITEMS CHAR(1) DEFAULT '0' NOT NULL,
FSCHEME BIGINT DEFAULT 0 NOT NULL
);


 EXEC p_AlterColumn 'T_BCM_REPORTLIST', 'FGROUPID', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_BIZRULE', 'FRUNSTATUS', 'CHAR(1)', 'NOT NULL', '0001', '''1''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ANALYSOLUSAVELOG') 
 CREATE TABLE T_BCM_ANALYSOLUSAVELOG (
FID BIGINT DEFAULT 0 NOT NULL,
FMODIFYITEM NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FOLDVALUE VARCHAR(100) DEFAULT ' ' NOT NULL,
FNEWVALUE VARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATEUSERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODELID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_INVELIMTPLENTRY' AND KSQL_COL_NAME ='FENTITYCOMB') 
 ALTER TABLE T_BCM_INVELIMTPLENTRY ADD (FENTITYCOMB CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DIMENSIONMAPNEW') 
 CREATE TABLE T_BCM_DIMENSIONMAPNEW (
ID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDIMENSION BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONMAP BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DATETYPEEDITCYCLE' AND KSQL_COL_NAME ='FVERSIONNAME') 
 ALTER TABLE T_BCM_DATETYPEEDITCYCLE ADD (FVERSIONNAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DATETYPEEDITCYCLE' AND KSQL_COL_NAME ='FVERSION') 
 ALTER TABLE T_BCM_DATETYPEEDITCYCLE ADD (FVERSION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DATETYPEEDITCYCLE' AND KSQL_COL_NAME ='FDESCRIBE') 
 ALTER TABLE T_BCM_DATETYPEEDITCYCLE ADD (FDESCRIBE NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DATETYPEEDITCYCLE' AND KSQL_COL_NAME ='FLATESTMODIFIERID') 
 ALTER TABLE T_BCM_DATETYPEEDITCYCLE ADD (FLATESTMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DATETYPEEDITCYCLE' AND KSQL_COL_NAME ='FLATESTMODIFYDATE') 
 ALTER TABLE T_BCM_DATETYPEEDITCYCLE ADD (FLATESTMODIFYDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_INVRELATIONDEFINE_L' AND KSQL_COL_NAME ='FENTRYID') 
 ALTER TABLE T_BCM_INVRELATIONDEFINE_L ADD (FENTRYID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_INVRELATIONDEFINE_L', 'FID', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ANALYTICSSOLUTIONS' AND KSQL_COL_NAME ='FTURNSTATUS') 
 ALTER TABLE T_BCM_ANALYTICSSOLUTIONS ADD (FTURNSTATUS INT DEFAULT 0 NOT NULL );

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