/**Begin C:\PDM_UPGRADE\PDM1\SRC_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT' AND KSQL_COL_NAME IN ('FAPTSCHEMEID')) 
 ALTER TABLE T_SRC_PROJECT ADD (FAPTSCHEMEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT' AND KSQL_COL_NAME IN ('FTECSCHEMEID')) 
 ALTER TABLE T_SRC_PROJECT ADD (FTECSCHEMEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT' AND KSQL_COL_NAME IN ('FBIZSCHEMEID')) 
 ALTER TABLE T_SRC_PROJECT ADD (FBIZSCHEMEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT' AND KSQL_COL_NAME IN ('FISOPENCONTROL')) 
 ALTER TABLE T_SRC_PROJECT ADD (FISOPENCONTROL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDDOCENTRY' AND KSQL_COL_NAME IN ('FSRCENTRYID')) 
 ALTER TABLE T_SRC_BIDDOCENTRY ADD (FSRCENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NEGOTIATEBILL' AND KSQL_COL_NAME IN ('FQUOTENUM')) 
 ALTER TABLE T_SRC_NEGOTIATEBILL ADD (FQUOTENUM CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_ENROLLSUPPLIER' AND KSQL_COL_NAME IN ('FAPPLYTIME')) 
 ALTER TABLE T_SRC_ENROLLSUPPLIER ADD (FAPPLYTIME DATETIME );
 EXEC p_AlterColumn 'T_SRC_INVITESUPPLIER', 'FSUPPLIERIP', 'NVARCHAR(100)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_BIDSCHEMECHG') 
 CREATE TABLE T_SRC_BIDSCHEMECHG (
FID BIGINT DEFAULT 0 NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FPENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSCHTEMPLATE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_BIDSCHEMECHGENTRY') 
 CREATE TABLE T_SRC_BIDSCHEMECHGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPACKAGEID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FNEWSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FINDEXTYPEID BIGINT DEFAULT 0 NOT NULL,
FWEIGHT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSRCENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_OPENSCHEME') 
 CREATE TABLE T_SRC_OPENSCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(300) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FBIZTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FENCRYPTNUM INT DEFAULT 0 NOT NULL,
FDECRYPTPASS CHAR(1) DEFAULT '3' NOT NULL,
FISENCRYPTBYPKG CHAR(1) DEFAULT '0' NOT NULL,
FSUPENCRYPTNUM INT DEFAULT 0 NOT NULL,
FSUPDECRYPTPASS CHAR(1) DEFAULT '2' NOT NULL,
FOPENNUM INT DEFAULT 0 NOT NULL,
FOPENPASS CHAR(1) DEFAULT '3' NOT NULL,
FISOPENBYPKG CHAR(1) DEFAULT '0' NOT NULL,
FSTATUS CHAR(1) DEFAULT 'C' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FISDEFAULT CHAR(1) DEFAULT '0' NOT NULL,
FMATCHFIELD INT DEFAULT 0 NOT NULL,
FISV_ID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_OPENSCHEME_L') 
 CREATE TABLE T_SRC_OPENSCHEME_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(300) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_OPENSOURCETYPE') 
 CREATE TABLE T_SRC_OPENSOURCETYPE (
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_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_OPENSOURCEFLOW') 
 CREATE TABLE T_SRC_OPENSOURCEFLOW (
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_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_OPENROLE') 
 CREATE TABLE T_SRC_OPENROLE (
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_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_ENCRYPTROLE') 
 CREATE TABLE T_SRC_ENCRYPTROLE (
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_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_BIDDOC_CHG') 
 CREATE TABLE T_SRC_BIDDOC_CHG (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FBIZSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FISQUICKPUR CHAR(1) DEFAULT '0' NOT NULL,
FMANAGETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FORIGIN VARCHAR(30) DEFAULT ' ' NOT NULL,
FPENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_BIDDOCENTRY_CHG') 
 CREATE TABLE T_SRC_BIDDOCENTRY_CHG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPACKAGEID BIGINT DEFAULT 0 NOT NULL,
FFILETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FFILENAME NVARCHAR(2000) DEFAULT ' ',
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FCOMPKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FFILEREQ NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISNEEDBIDDOC CHAR(1) DEFAULT '0' NOT NULL,
FSUPPLIERTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FISAPTITUDE CHAR(1) DEFAULT '0' NOT NULL,
FAPTITUDENOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPPLIERCODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FPACKFILENAME_NEW NVARCHAR(512) DEFAULT ' ' NOT NULL
);


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



/**End C:\PDM_UPGRADE\PDM1\SRC_table.sql **/
