/**Begin D:\PDM_UPGRADE\PDM1\HBSS_table.sql **/
-- 工作地表添加创建组织字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_WORKPLACE' AND KSQL_COL_NAME ='FCREATEORGID') 
 ALTER TABLE T_HBSS_WORKPLACE ADD (FCREATEORGID BIGINT DEFAULT 0 NOT NULL );


-- 用人单位表添加受控相关字段（原资料ID、位图、原资料位图）
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_ENTERPRISE' AND KSQL_COL_NAME ='FSOURCEDATAID') 
 ALTER TABLE T_HBSS_ENTERPRISE ADD (FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_ENTERPRISE' AND KSQL_COL_NAME ='FBITINDEX') 
 ALTER TABLE T_HBSS_ENTERPRISE ADD (FBITINDEX INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_ENTERPRISE' AND KSQL_COL_NAME ='FSOURCEBITINDEX') 
 ALTER TABLE T_HBSS_ENTERPRISE ADD (FSOURCEBITINDEX INT DEFAULT 0 NOT NULL );
 
-- 法律实体表添加受控相关字段（创建组织、控制策略、管理组织、使用组织、原资料ID、位图、原资料位图）
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITY' AND KSQL_COL_NAME ='FCREATEORGID') 
 ALTER TABLE T_HBSS_LAWENTITY ADD (FCREATEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITY' AND KSQL_COL_NAME ='FCTRLSTRATEGY') 
 ALTER TABLE T_HBSS_LAWENTITY ADD (FCTRLSTRATEGY VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITY' AND KSQL_COL_NAME ='FORGID') 
 ALTER TABLE T_HBSS_LAWENTITY ADD (FORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITY' AND KSQL_COL_NAME ='FUSEORGID') 
 ALTER TABLE T_HBSS_LAWENTITY ADD (FUSEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITY' AND KSQL_COL_NAME ='FSOURCEDATAID') 
 ALTER TABLE T_HBSS_LAWENTITY ADD (FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITY' AND KSQL_COL_NAME ='FBITINDEX') 
 ALTER TABLE T_HBSS_LAWENTITY ADD (FBITINDEX INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITY' AND KSQL_COL_NAME ='FSOURCEBITINDEX') 
 ALTER TABLE T_HBSS_LAWENTITY ADD (FSOURCEBITINDEX INT DEFAULT 0 NOT NULL );
 
-- 法律实体版本详情表添加创建组织、控制策略相关字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITYVRINF' AND KSQL_COL_NAME ='FCREATEORGID') 
 ALTER TABLE T_HBSS_LAWENTITYVRINF ADD (FCREATEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_LAWENTITYVRINF' AND KSQL_COL_NAME ='FCTRLSTRATEGY') 
 ALTER TABLE T_HBSS_LAWENTITYVRINF ADD (FCTRLSTRATEGY VARCHAR(10) DEFAULT ' ' NOT NULL );
/**End D:\PDM_UPGRADE\PDM1\HBSS_table.sql **/
