IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_ROLEDATARULE') 
 CREATE TABLE T_PERM_ROLEDATARULE (
FID BIGINT DEFAULT 0 NOT NULL,
FROLEID VARCHAR(18) DEFAULT ' ' NOT NULL,
FAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTITYNUM VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERMITEMID VARCHAR(18) DEFAULT ' ' NOT NULL,
FDATARULEID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_ROLEDATARULE_PROP') 
 CREATE TABLE T_PERM_ROLEDATARULE_PROP (
FID BIGINT DEFAULT 0 NOT NULL,
FROLEID VARCHAR(18) DEFAULT ' ' NOT NULL,
FAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTITYNUM VARCHAR(36) DEFAULT ' ' NOT NULL,
FPROPKEY VARCHAR(60) DEFAULT ' ' NOT NULL,
FPROPENTNUM VARCHAR(36) DEFAULT ' ' NOT NULL,
FDATARULEID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ROLEDATARULES' AND KSQL_COL_NAME IN ('FISUPDATE')) 
 ALTER TABLE T_PERM_ROLEDATARULES ADD (FISUPDATE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ROLEDATARULES' AND KSQL_COL_NAME IN ('FUPDATETIME')) 
 ALTER TABLE T_PERM_ROLEDATARULES ADD (FUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ROLEDATARULES' AND KSQL_COL_NAME IN ('FUPDATORID')) 
 ALTER TABLE T_PERM_ROLEDATARULES ADD (FUPDATORID BIGINT DEFAULT 0 NOT NULL );
  
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_OLDDATARULEENABLE' AND KSQL_COL_NAME IN ('FISNEWMODEL')) 
 ALTER TABLE T_PERM_OLDDATARULEENABLE ADD (FISNEWMODEL CHAR(1) DEFAULT '0' NOT NULL );


