/**Begin D:\PDM_UPGRADE\PDM1\BCM_table.sql **/

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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_PHASESUBMIT' AND KSQL_COL_NAME IN ('FISPERIODSTART')) 
 ALTER TABLE T_BCM_PHASESUBMIT ADD (FISPERIODSTART CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_OPLOGCONSOLE') 
 CREATE TABLE T_BCM_OPLOGCONSOLE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FSOURCEKEY VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FSUBSOURCEKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FAUDITDATE DATETIME,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FDESC VARCHAR(50) DEFAULT ' ' NOT NULL,
FOPCATEGORY VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_OPLOGCONSOLE_L') 
 CREATE TABLE T_BCM_OPLOGCONSOLE_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FDESC NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DOCUMENT') 
 CREATE TABLE T_BCM_DOCUMENT (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FLEVEL INT DEFAULT 1 NOT NULL,
FSEQ INT DEFAULT 1 NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FLONGNUMBER VARCHAR(1000) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(2000) DEFAULT ' ' NOT NULL,
FPERMID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_FILELISTENTITY') 
 CREATE TABLE T_BCM_FILELISTENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FLONGNUMBER VARCHAR(1000) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(2000) DEFAULT ' ' NOT NULL,
FCATALOG CHAR(1) DEFAULT '0' NOT NULL,
FPERMID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL
);


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



/**End D:\PDM_UPGRADE\PDM1\BCM_table.sql **/
