/**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_PERM_USRGRP_INH') 
 CREATE TABLE T_PERM_USRGRP_INH (
FID BIGINT DEFAULT 0 NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FCHILDRENID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATEFIELD DATETIME,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_USRGRPBIZROLE') 
 CREATE TABLE T_PERM_USRGRPBIZROLE (
FID BIGINT DEFAULT 0 NOT NULL,
FUSRGRPID BIGINT DEFAULT 0 NOT NULL,
FBIZROLEID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATEFIELD DATETIME,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_USRGRPROLE') 
 CREATE TABLE T_PERM_USRGRPROLE (
FID BIGINT DEFAULT 0 NOT NULL,
FUSRGRPID BIGINT DEFAULT 0 NOT NULL,
FROLEID VARCHAR(19) DEFAULT ' ' NOT NULL,
FCREATEDATEFIELD DATETIME,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_USRGRPROLE_DIMOBJ') 
 CREATE TABLE T_PERM_USRGRPROLE_DIMOBJ (
FID BIGINT DEFAULT 0 NOT NULL,
FUSR_USRGRP_RELID BIGINT DEFAULT 0 NOT NULL,
FDIMOBJID BIGINT DEFAULT 0 NOT NULL,
FDIMTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
FISINCLUDESUB CHAR(1) DEFAULT '0' NOT NULL,
FCREATEDATEFIELD DATETIME,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DISFUNPERM' AND KSQL_COL_NAME ='FISINCLUDESUBORG') 
 ALTER TABLE T_PERM_DISFUNPERM ADD (FISINCLUDESUBORG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERFIELDPERM' AND KSQL_COL_NAME ='FISINCLUDESUBORG') 
 ALTER TABLE T_PERM_USERFIELDPERM ADD (FISINCLUDESUBORG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERDATAPERM' AND KSQL_COL_NAME ='FISINCLUDESUBORG') 
 ALTER TABLE T_PERM_USERDATAPERM ADD (FISINCLUDESUBORG CHAR(1) DEFAULT '0' NOT NULL );

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