/**Begin D:\PDM_UPGRADE\pdm_new\BOS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_URDIM')
CREATE TABLE T_PERM_LOG_DIFF_URDIM (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FROLE_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FROLE_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDIM_ID BIGINT DEFAULT 0 NOT NULL,
FDIM_NUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FDIM_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINCLUDE_SUBORG CHAR(1) DEFAULT '0' NOT NULL,
FINCLUDE_SUBORG_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL,
FDIMTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FDIMTYPEDESC VARCHAR(30) DEFAULT ' ' NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FUSER_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUSER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FSTARTTIME DATETIME,
FENDTIME DATETIME,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_UBIZROLE')
CREATE TABLE T_PERM_LOG_DIFF_UBIZROLE (
FID BIGINT DEFAULT 0 NOT NULL,
FPERM_LOGID BIGINT DEFAULT 0 NOT NULL,
FUSER_ID BIGINT DEFAULT 0 NOT NULL,
FUSER_NAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUSER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FUSER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(36) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FROLE_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FROLE_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTARTTIME DATETIME,
FENDTIME DATETIME,
FOP_DESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FDATACHANGE_TYPE INT DEFAULT 0 NOT NULL,
FDATACHANGE_TYPE_DESC NVARCHAR(20) DEFAULT ' ' NOT NULL
);



/**  删除表 T_PERM_LOG_DIFF_UFUNC  */
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_UFUNC')
DROP TABLE T_PERM_LOG_DIFF_UFUNC;

/**  删除表 T_PERM_LOG_DIFF_UDISFUNC  */
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_LOG_DIFF_UDISFUNC')
DROP TABLE T_PERM_LOG_DIFF_UDISFUNC;


/**  直接授权、直接禁权日志表增加用户信息字段  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMDIS' AND KSQL_COL_NAME IN ('FUSER_ID'))
ALTER TABLE T_PERM_LOG_DIFF_DIMDIS ADD (FUSER_ID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMDIS' AND KSQL_COL_NAME IN ('FUSER_NAME'))
ALTER TABLE T_PERM_LOG_DIFF_DIMDIS ADD (FUSER_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMDIS' AND KSQL_COL_NAME IN ('FUSER_NUMBER'))
ALTER TABLE T_PERM_LOG_DIFF_DIMDIS ADD (FUSER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMDIS' AND KSQL_COL_NAME IN ('FUSER_USERNAME'))
ALTER TABLE T_PERM_LOG_DIFF_DIMDIS ADD (FUSER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMFUNC' AND KSQL_COL_NAME IN ('FUSER_ID'))
ALTER TABLE T_PERM_LOG_DIFF_DIMFUNC ADD (FUSER_ID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMFUNC' AND KSQL_COL_NAME IN ('FUSER_NAME'))
ALTER TABLE T_PERM_LOG_DIFF_DIMFUNC ADD (FUSER_NAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMFUNC' AND KSQL_COL_NAME IN ('FUSER_NUMBER'))
ALTER TABLE T_PERM_LOG_DIFF_DIMFUNC ADD (FUSER_NUMBER VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_LOG_DIFF_DIMFUNC' AND KSQL_COL_NAME IN ('FUSER_USERNAME'))
ALTER TABLE T_PERM_LOG_DIFF_DIMFUNC ADD (FUSER_USERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );



/**End D:\PDM_UPGRADE\pdm_new\BOS_table.sql **/
