/**Begin D:\utils\PDM_UPGRADE\PDM_UPGRADE\PDM1\HRCS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_SYSCAPABILITY')
CREATE TABLE T_HRCS_SYSCAPABILITY (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
                                      FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                      FSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
                                      FENABLE VARCHAR(2) DEFAULT ' ' NOT NULL,
                                      FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                      FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                      FBIZCLOUDID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                      FCAPABILITYTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
                                      FSERVICEORPLUGINNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                      FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                      FCREATETIME DATETIME,
                                      FMODIFYTIME DATETIME,
                                      FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                      FINDEX INT DEFAULT 0 NOT NULL,
                                      FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
                                      FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                      FDISABLEDATE DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_SYSCAPINPARAM')
CREATE TABLE T_HRCS_SYSCAPINPARAM (
                                      FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FSEQ INT DEFAULT 0 NOT NULL,
                                      FINPARAMNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FINPARAMTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
                                      FINPARAMBIZOBJECTID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                      FINOBJECTPROPERTY VARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FINISMUST VARCHAR(10) DEFAULT ' ' NOT NULL,
                                      FINPARAMDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_SYSCAPINPARAM_L')
CREATE TABLE T_HRCS_SYSCAPINPARAM_L (
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
                                        FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
                                        FINPARAMDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_SYSCAPOUTPARAM')
CREATE TABLE T_HRCS_SYSCAPOUTPARAM (
                                       FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                       FSEQ INT DEFAULT 0 NOT NULL,
                                       FOUTPARAMNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FOUTPARAMDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                       FOUTPARAMTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
                                       FOUTPARAMBIZOBJECTID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                       FID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_SYSCAPOUTPARAM_L')
CREATE TABLE T_HRCS_SYSCAPOUTPARAM_L (
                                         FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                         FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
                                         FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
                                         FOUTPARAMDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_SYSCAPABILITY' AND KSQL_COL_NAME ='FSERVICEORPLUGINNAME')
ALTER TABLE T_HRCS_SYSCAPABILITY ADD (FSERVICEORPLUGINNAME VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_SYSCAPABILITY' AND KSQL_COL_NAME ='FCAPABILITYTYPE')
ALTER TABLE T_HRCS_SYSCAPABILITY ADD (FCAPABILITYTYPE VARCHAR(10) DEFAULT ' ' NOT NULL );
EXEC p_AlterColumn 'T_HRCS_SYSCAPINPARAM', 'FINPARAMTYPE', 'VARCHAR(10)', 'NOT NULL', '0100', ''' ''';

/**End D:\utils\PDM_UPGRADE\PDM_UPGRADE\PDM1\HRCS_table.sql **/
