-- 资产卡片财务分录增加原始财务卡片字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_ASSET_FINENTRY' AND KSQL_COL_NAME IN ('FORIGINALFINCARDID'))
ALTER TABLE T_FA_ASSET_FINENTRY ADD (FORIGINALFINCARDID BIGINT DEFAULT 0 NOT NULL );

-- 增加索引
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ASSET_ENTRY_FINCARD') CREATE INDEX IDX_ASSET_ENTRY_FINCARD ON T_FA_ASSET_FINENTRY ( FFINCARDID );

-- 更新资产卡片财务分录原始财务卡片字段
update t_fa_asset_finentry set foriginalfincardid = ffincardid;