/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BOS_table.sql **/

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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSG_NOTICE') 
 CREATE TABLE T_MSG_NOTICE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCONTENT NCLOB DEFAULT ' ',
FCONTENT_TAG NCLOB DEFAULT ' ',
FMSGTYPEID BIGINT DEFAULT 0 NOT NULL,
FMSGCHANNELID BIGINT DEFAULT 0 NOT NULL,
FSENDSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FSENDTIME DATETIME,
FVALIDTIME BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSHOWTYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MSG_NOTICE' AND KSQL_COL_NAME ='FMESSAGEID')
 ALTER TABLE T_MSG_NOTICE ADD (FMESSAGEID BIGINT DEFAULT 0 NOT NULL );

 EXEC P_ALTERPK 'PK_T_MSG_NOTICE_L', 'T_MSG_NOTICE_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_MSG_NOTICE', 'T_MSG_NOTICE', 'FID', '1';

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

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BOS_table.sql **/
