/**Begin D:\pdm\PDM_UPGRADE\PDM1\HRCS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF') 
 CREATE TABLE T_HRCS_ESSYNCSCHEMECONF (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FQUERYENTITYID VARCHAR(18) DEFAULT ' ' NOT NULL,
FINITSTATE VARCHAR(2) DEFAULT '0' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FRELATIONTYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FONETOMANYENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FVERSION INT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ESSCHEMEDETAIL') 
 CREATE TABLE T_HRCS_ESSCHEMEDETAIL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FPARENTENTITYALIAS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCHILDENTITYALIAS VARCHAR(50) DEFAULT ' ' NOT NULL,
FARRAYFILED VARCHAR(100) DEFAULT ' ' NOT NULL,
FMODELTYPE VARCHAR(2) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF_L') 
 CREATE TABLE T_HRCS_ESSYNCSCHEMECONF_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ESSYNCRECORD') 
 CREATE TABLE T_HRCS_ESSYNCRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FESSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FSYNCMODE VARCHAR(10) DEFAULT ' ' NOT NULL,
FPLANSYNCTIME DATETIME,
FSTATUS VARCHAR(20) DEFAULT 'NONE' NOT NULL,
FFINISHEDSYNCTIME DATETIME,
FSYNCRANGESTART DATETIME,
FSYNCRANGEEND DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ESCONFIGWHITEBILL') 
 CREATE TABLE T_HRCS_ESCONFIGWHITEBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FQUERYENTITYID VARCHAR(18) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ESCONFIG')
 CREATE TABLE T_HRCS_ESCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FIP VARCHAR(50) DEFAULT ' ' NOT NULL,
FPORT INT DEFAULT 0 NOT NULL,
FUSERNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FPASSWORD VARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBSS_ENTITYRELEASEINFO' AND KSQL_COL_NAME IN ('FBIZAPPLYTYPE')) 
 ALTER TABLE T_HBSS_ENTITYRELEASEINFO ADD (FBIZAPPLYTYPE VARCHAR(2) DEFAULT '1' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF' AND KSQL_COL_NAME IN ('FMASTERID'))
 ALTER TABLE T_HRCS_ESSYNCSCHEMECONF ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF' AND KSQL_COL_NAME IN ('FSIMPLENAME'))
 ALTER TABLE T_HRCS_ESSYNCSCHEMECONF ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF' AND KSQL_COL_NAME IN ('FISSYSPRESET'))
 ALTER TABLE T_HRCS_ESSYNCSCHEMECONF ADD (FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF' AND KSQL_COL_NAME IN ('FINDEX'))
 ALTER TABLE T_HRCS_ESSYNCSCHEMECONF ADD (FINDEX INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF' AND KSQL_COL_NAME IN ('FDISABLERID'))
 ALTER TABLE T_HRCS_ESSYNCSCHEMECONF ADD (FDISABLERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF' AND KSQL_COL_NAME IN ('FDISABLEDATE'))
 ALTER TABLE T_HRCS_ESSYNCSCHEMECONF ADD (FDISABLEDATE DATETIME );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCSCHEMECONF_L' AND KSQL_COL_NAME IN ('FSIMPLENAME'))
 ALTER TABLE T_HRCS_ESSYNCSCHEMECONF_L ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSCHEMEDETAIL' AND KSQL_COL_NAME IN ('FSEQ'))
 ALTER TABLE T_HRCS_ESSCHEMEDETAIL ADD (FSEQ INT DEFAULT 0 NOT NULL );
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ESSYNCRECORD' AND KSQL_COL_NAME IN ('FESSYNCTIME'))
 ALTER TABLE T_HRCS_ESSYNCRECORD ADD (FESSYNCTIME DATETIME );
EXEC p_AlterColumn 'T_HRCS_ESCONFIGWHITEBILL', 'FQUERYENTITYID', 'VARCHAR(18)', 'NOT NULL', '1111', ''' ''';
EXEC p_AlterColumn 'T_HRCS_ESSYNCSCHEMECONF', 'FNUMBER', 'VARCHAR(60)', 'NOT NULL', '0100', ''' ''';
EXEC p_AlterColumn 'T_HRCS_ESSYNCSCHEMECONF', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';
EXEC p_AlterColumn 'T_HRCS_ESSYNCSCHEMECONF_L', 'FNAME', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';
/**End D:\pdm\PDM_UPGRADE\PDM1\HRCS_table.sql **/
