-- 执行状态：测试环境已执行
-- 测试环境：test
-- 测试执行时间：2026-07-30 10:06:47 +0800
-- 正式环境：未执行
-- 石河子智慧就业：人才服务岗位推送关联表。
-- 关联岗位 ID 与身份证号；is_push=0 表示未推送，is_push=1 表示已推送。
-- 可重复执行，不写入业务测试数据。

BEGIN;

SET LOCAL search_path = shz, public;

CREATE SEQUENCE IF NOT EXISTS job_push_record_id_seq
    START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;

CREATE TABLE IF NOT EXISTS job_push_record (
    id          BIGINT NOT NULL DEFAULT nextval('job_push_record_id_seq') PRIMARY KEY,
    job_id      BIGINT NOT NULL,
    id_number   VARCHAR(32) NOT NULL,
    is_push     SMALLINT NOT NULL DEFAULT 0,
    push_time   TIMESTAMP(0),
    create_time TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    update_time TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    remark      VARCHAR(500)
);

COMMENT ON TABLE job_push_record IS '人才服务岗位推送关联表';
COMMENT ON COLUMN job_push_record.job_id IS '石河子岗位 ID，关联 job.job_id';
COMMENT ON COLUMN job_push_record.id_number IS '被推送人的身份证号';
COMMENT ON COLUMN job_push_record.is_push IS '是否已推送：0未推送，1已推送';
COMMENT ON COLUMN job_push_record.push_time IS '最近一次推送时间';

CREATE UNIQUE INDEX IF NOT EXISTS uk_job_push_record_job_id_number
    ON job_push_record (job_id, id_number);
CREATE INDEX IF NOT EXISTS idx_job_push_record_id_number
    ON job_push_record (id_number);
CREATE INDEX IF NOT EXISTS idx_job_push_record_is_push
    ON job_push_record (is_push);

COMMIT;
