/**合同签约**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CONTRACTSIGN')
CREATE TABLE T_ER_CONTRACTSIGN (
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FCONTRACTBILLNO VARCHAR(80) DEFAULT ' ' NOT NULL,
                                   FCONTRACTID BIGINT DEFAULT 0 NOT NULL,
                                   FBILLSTATUS VARCHAR(1) DEFAULT ' ' NOT NULL,
                                   FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                   FCREATETIME DATETIME,
                                   FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                   FMODIFYTIME DATETIME,
                                   FPARTAPERSON VARCHAR(80) DEFAULT ' ' NOT NULL,
                                   FPARTBPERSON VARCHAR(80) DEFAULT ' ' NOT NULL,
                                   FPARTOTHERPERSON VARCHAR(80) DEFAULT ' ' NOT NULL,
                                   FENDDATE DATETIME,
                                   FSIGNDATE DATETIME,
                                   FSIGNADDRESS NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FSIGNADDRESSDETAIL NVARCHAR(255) DEFAULT ' ' NOT NULL
);


EXEC P_ALTERPK 'PK_T_ER_CONTRACTSIGN', 'T_ER_CONTRACTSIGN', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_CONTRACTSIGN_FBNO') CREATE INDEX IDX_ER_CONTRACTSIGN_FBNO ON T_ER_CONTRACTSIGN ( FCONTRACTBILLNO );




/****合同台账添加签约人，签约地址字段***/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_CONTRACTBILL' AND KSQL_COL_NAME ='FSIGNADDRESS')
ALTER TABLE T_ER_CONTRACTBILL ADD (FSIGNADDRESS NVARCHAR(50) DEFAULT ' ' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_CONTRACTBILL' AND KSQL_COL_NAME ='FSIGNADDRESSDETAIL')
ALTER TABLE T_ER_CONTRACTBILL ADD (FSIGNADDRESSDETAIL NVARCHAR(255) DEFAULT ' ' NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_CONTRACTPARTY' AND KSQL_COL_NAME ='FPARTPERSON')
ALTER TABLE T_ER_CONTRACTPARTY ADD (FPARTPERSON  VARCHAR(80) DEFAULT ' ' NOT NULL);

