/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BOS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EC_COMPANYAUTH') 
 CREATE TABLE T_EC_COMPANYAUTH (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FCONTRACTSUBID BIGINT DEFAULT 0 NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FSIGNPROVIDER VARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMPANYSEAL VARCHAR(255) DEFAULT ' ' NOT NULL,
FKDAPPID VARCHAR(100) DEFAULT ' ' NOT NULL,
FAPPID VARCHAR(100) DEFAULT ' ' NOT NULL,
FISAUTHED CHAR(1) DEFAULT ' ' NOT NULL,
FCOMPANYID VARCHAR(100) DEFAULT ' ' NOT NULL,
FAUTHURL VARCHAR(512) DEFAULT ' ' NOT NULL,
FRESULTCODE VARCHAR(10) DEFAULT ' ' NOT NULL,
FRESULTDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
FSIGNATUREID VARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(15) DEFAULT ' ' 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,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EC_CONTRACTSUBJECT') 
 CREATE TABLE T_EC_CONTRACTSUBJECT (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FFIORGID BIGINT DEFAULT 0 NOT NULL,
FSIGNPROVIDER VARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMPANYSEAL VARCHAR(255) DEFAULT ' ' NOT NULL,
FKDAPPID VARCHAR(100) DEFAULT ' ' NOT NULL,
FUUID VARCHAR(100) DEFAULT ' ' NOT NULL,
FAPPID VARCHAR(100) DEFAULT ' ' NOT NULL,
FISAUTHED CHAR(1) DEFAULT ' ' NOT NULL,
FCOMPANYID VARCHAR(100) DEFAULT ' ' NOT NULL,
FAUTHURL VARCHAR(512) DEFAULT ' ' NOT NULL,
FRESULTCODE VARCHAR(10) DEFAULT ' ' NOT NULL,
FRESULTDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
FSIGNATUREID VARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(15) DEFAULT ' ' 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,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


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

 EXEC P_ALTERPK 'PK_T_EC_COMPANYAUTH', 'T_EC_COMPANYAUTH', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EC_COMPANYAUTH_BIZPARTNER') CREATE INDEX IDX_EC_COMPANYAUTH_BIZPARTNER ON T_EC_COMPANYAUTH ( FBIZPARTNERID );


 EXEC P_ALTERPK 'PK_T_EC_COMPANYAUTH_L', 'T_EC_COMPANYAUTH_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EC_COMPANYAUTH_L_FID') CREATE INDEX IDX_T_EC_COMPANYAUTH_L_FID ON T_EC_COMPANYAUTH_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_EC_CONTRACTSUBJECT', 'T_EC_CONTRACTSUBJECT', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EC_CONTRACTSUBJECT_ORGID') CREATE INDEX IDX_EC_CONTRACTSUBJECT_ORGID ON T_EC_CONTRACTSUBJECT ( FFIORGID );


 EXEC P_ALTERPK 'PK_T_EC_CONTRACTSUBJECT_L', 'T_EC_CONTRACTSUBJECT_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EC_CONTRACTSUBJECT_L_FID') CREATE INDEX IDX_T_EC_CONTRACTSUBJECT_L_FID ON T_EC_CONTRACTSUBJECT_L ( FID ,FLOCALEID );


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