/* T_CAS_BALANCELOG 余额变更日志表； */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_BALANCELOG')
CREATE TABLE T_CAS_BALANCELOG
(
    FID               BIGINT DEFAULT 0 NOT NULL,
	FBALANCETYPE      CHAR(1)  DEFAULT '0' NOT NULL,
	FSOURCEBILLID     BIGINT DEFAULT 0 NOT NULL,
	FSOURCEBILLNO     VARCHAR(60) DEFAULT ' ' NOT NULL,
	FORGID            BIGINT DEFAULT 0 NOT NULL,
	FBANKACCTID       BIGINT DEFAULT 0 NOT NULL,
	FCASHACCTID       BIGINT DEFAULT 0 NOT NULL,
	FCURRENCYID       BIGINT DEFAULT 0 NOT NULL,
	FAMOUNT           DECIMAL(23,10) DEFAULT 0 NOT NULL ,
	FISDEBIT          CHAR(1)  DEFAULT '0' NOT NULL,
	FBIZDATE          DATETIME,
	FCOUNT            INT DEFAULT 0 NOT NULL ,
	FOPERATETYPE      VARCHAR(50) DEFAULT ' ' NOT NULL,
	FISDO             CHAR(1)  DEFAULT '0' NOT NULL,
	FCREATDATE        DATETIME,
	FCREATER          BIGINT DEFAULT 0 NOT NULL
);

EXEC P_ALTERPK 'PK_T_CAS_BALANCELOG', 'T_CAS_BALANCELOG', 'FID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CAS_BALMLOG_FBALANCETYPE') CREATE INDEX IDX_CAS_BALMLOG_FBALANCETYPE ON T_CAS_BALANCELOG ( FBALANCETYPE,FORGID );
