
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_INSTANTMSGTYPE') 
 CREATE TABLE T_BAS_INSTANTMSGTYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_INSTANTMSGTYPE_L') 
 CREATE TABLE T_BAS_INSTANTMSGTYPE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_IMMAPPING') 
 CREATE TABLE T_BAS_IMMAPPING (
FID BIGINT DEFAULT 0 NOT NULL,
FIMTYPEID BIGINT DEFAULT 0 NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FOPENID VARCHAR(80) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_T_BAS_INSTANTMSGTYPE', 'T_BAS_INSTANTMSGTYPE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_BAS_INSTANTMSGTYPE_NUM') CREATE INDEX IDX_T_BAS_INSTANTMSGTYPE_NUM ON T_BAS_INSTANTMSGTYPE ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_BAS_INSTANTMSGTYPE_L', 'T_BAS_INSTANTMSGTYPE_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_BAS_INSTANTMSGTYPE_L_FID') CREATE INDEX IDX_T_BAS_INSTANTMSGTYPE_L_FID ON T_BAS_INSTANTMSGTYPE_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_BAS_IMMAPPING', 'T_BAS_IMMAPPING', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BAS_IMMAP_TYPEUSEROPEN') CREATE INDEX IDX_BAS_IMMAP_TYPEUSEROPEN ON T_BAS_IMMAPPING ( FIMTYPEID ,FUSERID ,FOPENID );

