-- 租赁终止相关字段、表结构
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW' AND KSQL_COL_NAME IN ('FSRCCONTRACTID'))
 ALTER TABLE T_FA_LEASE_CONTRACT_NEW ADD (FSRCCONTRACTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW' AND KSQL_COL_NAME IN ('FLEASETERMINATIONDATE'))
 ALTER TABLE T_FA_LEASE_CONTRACT_NEW ADD (FLEASETERMINATIONDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW' AND KSQL_COL_NAME IN ('FCLEARBILLID'))
 ALTER TABLE T_FA_LEASE_CONTRACT_NEW ADD (FCLEARBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW' AND KSQL_COL_NAME IN ('FBIZSTATUS'))
 ALTER TABLE T_FA_LEASE_CONTRACT_NEW ADD (FBIZSTATUS CHAR(1) DEFAULT 'A' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW' AND KSQL_COL_NAME IN ('FRENEWALCONTRACTID'))
 ALTER TABLE T_FA_LEASE_CONTRACT_NEW ADD (FRENEWALCONTRACTID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW_WB')
 CREATE TABLE T_FA_LEASE_CONTRACT_NEW_WB (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRULEVERID BIGINT DEFAULT 0 NOT NULL,
FRULEITEMID BIGINT DEFAULT 0 NOT NULL,
FOPERATE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FWRITEVALUE DECIMAL(23,10) DEFAULT 0.0000000000 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW_LK')
 CREATE TABLE T_FA_LEASE_CONTRACT_NEW_LK (
FID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_LEASE_CONTRACT_NEW_TC')
 CREATE TABLE T_FA_LEASE_CONTRACT_NEW_TC (
FID BIGINT DEFAULT 0 NOT NULL,
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTTABLEID BIGINT DEFAULT 0 NOT NULL,
FTID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);