/**  t_perm_userrole 增加 FFROMTYPEDESC  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERROLE' AND KSQL_COL_NAME IN ('FFROMTYPEDESC'))
ALTER TABLE T_PERM_USERROLE ADD (FFROMTYPEDESC NVARCHAR(255) DEFAULT ' ' );

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

IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PERM_CONFIG_L')
DROP TABLE T_PERM_CONFIG_L;

/**  t_perm_userbizrole 增加 FFROMTYPEDESC  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERBIZROLE' AND KSQL_COL_NAME IN ('FFROMTYPEDESC'))
ALTER TABLE T_PERM_USERBIZROLE ADD (FFROMTYPEDESC NVARCHAR(255) DEFAULT ' ' );


/**  t_perm_userpermdetail、t_perm_disfunperm 增加 FFROMTYPEDESC  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DISFUNPERM' AND KSQL_COL_NAME IN ('FFROMTYPEDESC'))
ALTER TABLE T_PERM_DISFUNPERM ADD (FFROMTYPEDESC NVARCHAR(255) DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERPERMDETAIL' AND KSQL_COL_NAME IN ('FFROMTYPEDESC'))
ALTER TABLE T_PERM_USERPERMDETAIL ADD (FFROMTYPEDESC NVARCHAR(255) DEFAULT ' ' );

/**  t_perm_userpermdetail、t_perm_disfunperm 增加 创建人、创建时间、修改人、修改时间  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERPERMDETAIL' AND KSQL_COL_NAME IN ('FCREATORID'))
ALTER TABLE T_PERM_USERPERMDETAIL ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERPERMDETAIL' AND KSQL_COL_NAME IN ('FCREATETIME'))
ALTER TABLE T_PERM_USERPERMDETAIL ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERPERMDETAIL' AND KSQL_COL_NAME IN ('FMODIFIERID'))
ALTER TABLE T_PERM_USERPERMDETAIL ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USERPERMDETAIL' AND KSQL_COL_NAME IN ('FMODIFYTIME'))
ALTER TABLE T_PERM_USERPERMDETAIL ADD (FMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DISFUNPERM' AND KSQL_COL_NAME IN ('FCREATORID'))
ALTER TABLE T_PERM_DISFUNPERM ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DISFUNPERM' AND KSQL_COL_NAME IN ('FCREATETIME'))
ALTER TABLE T_PERM_DISFUNPERM ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DISFUNPERM' AND KSQL_COL_NAME IN ('FMODIFIERID'))
ALTER TABLE T_PERM_DISFUNPERM ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DISFUNPERM' AND KSQL_COL_NAME IN ('FMODIFYTIME'))
ALTER TABLE T_PERM_DISFUNPERM ADD (FMODIFYTIME DATETIME );

/**  t_perm_usrgrpbizrole 增加 修改人、修改时间、来源描述  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USRGRPBIZROLE' AND KSQL_COL_NAME IN ('FMODIFYDATEFIELD'))
ALTER TABLE T_PERM_USRGRPBIZROLE ADD (FMODIFYDATEFIELD DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USRGRPBIZROLE' AND KSQL_COL_NAME IN ('FMODIFIERFIELD'))
ALTER TABLE T_PERM_USRGRPBIZROLE ADD (FMODIFIERFIELD BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USRGRPBIZROLE' AND KSQL_COL_NAME IN ('FFROMTYPEDESC'))
ALTER TABLE T_PERM_USRGRPBIZROLE ADD (FFROMTYPEDESC NVARCHAR(255) DEFAULT ' ' );

/**  t_perm_usrgrprole 增加 来源描述  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_USRGRPROLE' AND KSQL_COL_NAME IN ('FFROMTYPEDESC'))
ALTER TABLE T_PERM_USRGRPROLE ADD (FFROMTYPEDESC NVARCHAR(255) DEFAULT ' ' );

/**  t_sec_usergroupstaff 增加 创建人、创建时间、修改人、修改时间、来源描述  */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SEC_USERGROUPSTAFF' AND KSQL_COL_NAME IN ('FCREATORID'))
ALTER TABLE T_SEC_USERGROUPSTAFF ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SEC_USERGROUPSTAFF' AND KSQL_COL_NAME IN ('FCREATETIME'))
ALTER TABLE T_SEC_USERGROUPSTAFF ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SEC_USERGROUPSTAFF' AND KSQL_COL_NAME IN ('FMODIFIERID'))
ALTER TABLE T_SEC_USERGROUPSTAFF ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SEC_USERGROUPSTAFF' AND KSQL_COL_NAME IN ('FMODIFYTIME'))
ALTER TABLE T_SEC_USERGROUPSTAFF ADD (FMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SEC_USERGROUPSTAFF' AND KSQL_COL_NAME IN ('FFROMTYPEDESC'))
ALTER TABLE T_SEC_USERGROUPSTAFF ADD (FFROMTYPEDESC NVARCHAR(255) DEFAULT ' ' );

