/**聊天历史记录表**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHAT_HISTORY')
CREATE TABLE T_ER_CHAT_HISTORY (
   FID BIGINT DEFAULT 0 NOT NULL,
   FNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
   FNAME VARCHAR(30) DEFAULT ' ' NOT NULL,
   FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
   FCREATORID BIGINT DEFAULT 0 NOT NULL,
   FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
   FCREATETIME DATETIME,
   FMODIFYTIME DATETIME,
   FMASTERID BIGINT DEFAULT 0 NOT NULL,
   FCHATUSER BIGINT DEFAULT 0 NOT NULL,
   FOPERATETIME DATETIME,
   FENABLE VARCHAR(50) DEFAULT ' ' NOT NULL
);
EXEC p_AlterPK 'PK_ER_CHAT_HISTORY', 'T_ER_CHAT_HISTORY', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_CHAT_HISTORY' AND KSQL_INDNAME = 'IDX_ER_CHAT_HISTORY')
CREATE INDEX IDX_ER_CHAT_HISTORY ON T_ER_CHAT_HISTORY (FNUMBER);

/**聊天历史记录多语言表**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHAT_HISTORY_L')
CREATE TABLE T_ER_CHAT_HISTORY_L (
 FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
 FID BIGINT DEFAULT 0 NOT NULL,
 FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
 FNAME VARCHAR(100) DEFAULT ' ' NOT NULL
);

EXEC p_AlterPK 'PK_ER_CHAT_HISTORY_L', 'T_ER_CHAT_HISTORY_L', 'FPKID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_CHAT_HISTORY_L' AND KSQL_INDNAME = 'IDX_ER_CHAT_HISTORY_L')
CREATE INDEX IDX_ER_CHAT_HISTORY_L ON T_ER_CHAT_HISTORY_L (FID ,FLOCALEID);

/**聊天历史记录分录表**/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHAT_CONTENT')
CREATE TABLE T_ER_CHAT_CONTENT (
   FID BIGINT DEFAULT 0 NOT NULL,
   FENTRYID BIGINT DEFAULT 0 NOT NULL,
   FSEQ INT DEFAULT 0 NOT NULL,
   FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
   FSKILLID BIGINT DEFAULT 0 NOT NULL,
   FSKILLTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
   FCONTENT   VARCHAR(255)  DEFAULT ' ' NOT NULL,
   FCONTENT_TAG NCLOB,
   FCREATETIME DATETIME,
   FCHATMODIFYTIME DATETIME,
   FCOMMENT VARCHAR(50) DEFAULT ' ' NOT NULL,
   FMESSAGEID VARCHAR(100) DEFAULT ' ' NOT NULL,
   FPARENTID VARCHAR(100) DEFAULT ' ' NOT NULL,
   FMSGTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
   FDISLIKECONTENT VARCHAR(2000) DEFAULT ' ' NOT NULL
);
EXEC p_AlterPK 'PK_ER_CHAT_CONTENT', 'T_ER_CHAT_CONTENT', 'FENTRYID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_ER_CHAT_CONTENT' AND KSQL_INDNAME = 'IDX_ER_CHAT_CONTENT')
CREATE INDEX IDX_ER_CHAT_CONTENT ON T_ER_CHAT_CONTENT (FID ,FMESSAGEID);





