/**Begin D:\PDM_UPGRADE\PDM1\TM_table.sql **/
--外汇掉期添加远端持仓金额，生命周期添加识别掉期近远端字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_F' AND KSQL_COL_NAME IN ('FFARBIZRESTAMT'))
 ALTER TABLE T_TM_TRADE_F ADD (FFARBIZRESTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_F' AND KSQL_COL_NAME IN ('FISOVERNIGHT'))
 ALTER TABLE T_TM_TRADE_F ADD (FISOVERNIGHT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_F' AND KSQL_COL_NAME IN ('FSWAPTYPE'))
 ALTER TABLE T_TM_TRADE_F ADD (FSWAPTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_F' AND KSQL_COL_NAME IN ('FOFFSET_FAR'))
 ALTER TABLE T_TM_TRADE_F ADD (FOFFSET_FAR INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE_F' AND KSQL_COL_NAME IN ('FOFFSET'))
 ALTER TABLE T_TM_TRADE_F ADD (FOFFSET INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_BIZRECORD' AND KSQL_COL_NAME IN ('FSWAPDIR'))
 ALTER TABLE T_TM_BIZRECORD ADD (FSWAPDIR NVARCHAR(30) DEFAULT ' ' NOT NULL );

--交易添加授信字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE' AND KSQL_COL_NAME IN ('FCREDITVARIETYID'))
 ALTER TABLE T_TM_TRADE ADD (FCREDITVARIETYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_TRADE' AND KSQL_COL_NAME IN ('FUSEDCREDITID'))
 ALTER TABLE T_TM_TRADE ADD (FUSEDCREDITID BIGINT DEFAULT 0 NOT NULL );
/**End D:\PDM_UPGRADE\PDM1\TM_table.sql **/
