/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TSRBD_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_BIZCONFIGDATA_L') 
 CREATE TABLE T_TSRBD_BIZCONFIGDATA_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME VARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL
);

-- 切环境报错暂时注掉
-- EXEC p_AlterColumn 'T_TSRBD_BIZCONFIGDATA', 'FDATA', 'VARCHAR(5000)', 'NOT NULL', '0100', ''' ''';


--offer模版国家地区
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_OFFERCOUNTRY')
CREATE TABLE T_TSRBD_OFFERCOUNTRY (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

--offer模版招聘场景
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_OFFERRECRUSCENE')
CREATE TABLE T_TSRBD_OFFERRECRUSCENE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

--offer模版语言
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TSRBD_OFFERTEMPLATE' AND KSQL_COL_NAME ='FLANGUETYPEID')
ALTER TABLE T_TSRBD_OFFERTEMPLATE ADD (FLANGUETYPEID BIGINT DEFAULT 0 NOT NULL );

-- 招聘渠道 start
EXEC p_AlterColumn 'T_TSRBD_RECRUCHNLNM', 'FSTATUS', 'VARCHAR(10)', 'NOT NULL', '0100', ''' ''';

EXEC p_AlterColumn 'T_TSRBD_RECRUCHNLNM', 'FENABLE', 'VARCHAR(10)', 'NOT NULL', '0100', ''' ''';

EXEC p_AlterColumn 'T_TSRBD_RECRUCHNLNM', 'FISSYSPRESET', 'VARCHAR(1)', 'NOT NULL', '1111', ''' ''';

EXEC p_AlterColumn 'T_TSRBD_RECRUCHNLNM', 'FMULTIFUNCTIONAL', 'VARCHAR(10)', 'NOT NULL', '0100', ''' ''';

EXEC p_AlterColumn 'T_TSRBD_RECRUCHNLNM', 'FWEBSITE', 'VARCHAR(200)', 'NOT NULL', '1111', ''' ''';

EXEC p_AlterColumn 'T_TSRBD_RECRUCHNLNM', 'FADVERTISEMENT', 'VARCHAR(10)', 'NOT NULL', '0100', ''' ''';

EXEC p_AlterColumn 'T_TSRBD_RECRUCHNLNM', 'FCHANNELPIC', 'VARCHAR(255)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TSRBD_RECRUCHNLNM' AND KSQL_COL_NAME ='FEFFTIME')
ALTER TABLE T_TSRBD_RECRUCHNLNM ADD (FEFFTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TSRBD_RECRUCHNLNM' AND KSQL_COL_NAME ='FEXPIRETIME')
ALTER TABLE T_TSRBD_RECRUCHNLNM ADD (FEXPIRETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TSRBD_RECRUCHNLNM' AND KSQL_COL_NAME ='FREGISTEREDADDR')
ALTER TABLE T_TSRBD_RECRUCHNLNM ADD (FREGISTEREDADDR VARCHAR(300) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TSRBD_RECRUCHNLNM' AND KSQL_COL_NAME ='FESTABLISHDATE')
ALTER TABLE T_TSRBD_RECRUCHNLNM ADD (FESTABLISHDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TSRBD_RECRUCHNLNM' AND KSQL_COL_NAME ='FCITYID')
ALTER TABLE T_TSRBD_RECRUCHNLNM ADD (FCITYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TSRBD_RECRUCHNLNM' AND KSQL_COL_NAME ='FBASEDATAFIELD')
ALTER TABLE T_TSRBD_RECRUCHNLNM ADD (FBASEDATAFIELD BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_RECCOUNTRY')
CREATE TABLE T_TSRBD_RECCOUNTRY (
                                    FPKID BIGINT DEFAULT 0 NOT NULL,
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_RECORG')
CREATE TABLE T_TSRBD_RECORG (
                                FPKID BIGINT DEFAULT 0 NOT NULL,
                                FID BIGINT DEFAULT 0 NOT NULL,
                                FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_RECJOBLEVEL')
CREATE TABLE T_TSRBD_RECJOBLEVEL (
                                     FPKID BIGINT DEFAULT 0 NOT NULL,
                                     FID BIGINT DEFAULT 0 NOT NULL,
                                     FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_CHANNELCONTACT')
CREATE TABLE T_TSRBD_CHANNELCONTACT (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
                                        FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                        FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                        FENABLE VARCHAR(10) DEFAULT ' ' NOT NULL,
                                        FCREATETIME DATETIME,
                                        FMODIFYTIME DATETIME,
                                        FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                        FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                        FINDEX INT DEFAULT 0 NOT NULL,
                                        FISSYSPRESET VARCHAR(1) DEFAULT ' ' NOT NULL,
                                        FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                        FDISABLEDATE DATETIME,
                                        FRECRUCHNLNMID BIGINT DEFAULT 0 NOT NULL,
                                        FEMAIL VARCHAR(320) DEFAULT ' ' NOT NULL,
                                        FTELEPHONE VARCHAR(30) DEFAULT ' ' NOT NULL,
                                        FCONTACTTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
                                        FEXPERTISE VARCHAR(300) DEFAULT ' ' NOT NULL,
                                        FREMARKS VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_CHANNELCONTACT_L')
CREATE TABLE T_TSRBD_CHANNELCONTACT_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_TSRBD_CHANNELCONTRACT')
CREATE TABLE T_TSRBD_CHANNELCONTRACT (
                                         FID BIGINT DEFAULT 0 NOT NULL,
                                         FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
                                         FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                         FCONTRACTNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
                                         FRECRUCHNLNMID BIGINT DEFAULT 0 NOT NULL,
                                         FCONTRACTSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
                                         FCONTRACTSTARTDATE DATETIME,
                                         FCONTRACTENDDATE DATETIME,
                                         FCURRENCY BIGINT DEFAULT 0 NOT NULL,
                                         FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                         FAMOUNTUNIT VARCHAR(10) DEFAULT ' ' NOT NULL,
                                         FRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                         FTERM VARCHAR(300) DEFAULT ' ' NOT NULL,
                                         FSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
                                         FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                         FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                         FENABLE VARCHAR(10) DEFAULT ' ' NOT NULL,
                                         FCREATETIME DATETIME,
                                         FMODIFYTIME DATETIME,
                                         FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                         FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                         FDESCRIPTION NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                         FINDEX INT DEFAULT 0 NOT NULL,
                                         FISSYSPRESET VARCHAR(1) DEFAULT ' ' NOT NULL,
                                         FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                         FDISABLEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_CHANNELCONTRACT_L')
CREATE TABLE T_TSRBD_CHANNELCONTRACT_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(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TSRBD_CHNLNCONTRACTORG')
CREATE TABLE T_TSRBD_CHNLNCONTRACTORG (
                                          FPKID BIGINT DEFAULT 0 NOT NULL,
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
-- 招聘渠道 end
/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TSRBD_table.sql **/
