/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SYS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_DINGDING') 
 CREATE TABLE T_BAS_DINGDING (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAPPKEY VARCHAR(100) DEFAULT ' ' NOT NULL,
FAPPSECRET VARCHAR(100) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '0' NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
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_DINGDING_L') 
 CREATE TABLE T_BAS_DINGDING_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_WXGZH') 
 CREATE TABLE T_BAS_WXGZH (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAPPID VARCHAR(100) DEFAULT ' ' NOT NULL,
FSECRET VARCHAR(100) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '0' NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
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_WXGZH_L') 
 CREATE TABLE T_BAS_WXGZH_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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_OPEN_APISERVICE' AND KSQL_COL_NAME ='FALLOWGUEST') 
 ALTER TABLE T_OPEN_APISERVICE ADD (FALLOWGUEST CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_BAS_IMPORTTEMPLATE_L', 'FCOMMENT', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BAS_ASSISTANTDATA' AND KSQL_COL_NAME ='FCREATEORGID') 
 ALTER TABLE T_BAS_ASSISTANTDATA ADD (FCREATEORGID BIGINT DEFAULT 100000 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BAS_ASSISTANTDATA' AND KSQL_COL_NAME ='FCTRLVIEWID') 
 ALTER TABLE T_BAS_ASSISTANTDATA ADD (FCTRLVIEWID BIGINT DEFAULT 16 NOT NULL );
 EXEC p_AlterColumn 'T_BAS_ASSISTANTDATAENTRY', 'FCREATEORGID', 'BIGINT', 'NOT NULL', '1111', '0';

 EXEC p_AlterColumn 'T_BAS_ASSISTANTDATAENTRY', 'FUSEORGID', 'BIGINT', 'NOT NULL', '1111', '0';


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