-- 户外招聘会签到人员表
-- 依赖：shz.cms_outdoor_fair（fair_id 外键逻辑关联，不建物理外键）

CREATE SEQUENCE IF NOT EXISTS shz.cms_outdoor_fair_attendee_id_seq
    START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;

CREATE TABLE IF NOT EXISTS shz.cms_outdoor_fair_attendee (
    id            BIGINT       NOT NULL DEFAULT nextval('shz.cms_outdoor_fair_attendee_id_seq'::regclass) PRIMARY KEY,
    fair_id       BIGINT       NOT NULL,
    name          VARCHAR(64)  NOT NULL,
    phone         VARCHAR(20),
    address       VARCHAR(255),
    check_in_time TIMESTAMP,
    create_by     VARCHAR(64),
    create_time   TIMESTAMP,
    update_by     VARCHAR(64),
    update_time   TIMESTAMP,
    remark        VARCHAR(500),
    del_flag      CHAR(1)      DEFAULT '0'
);

CREATE INDEX IF NOT EXISTS idx_cms_outdoor_fair_attendee_fair
    ON shz.cms_outdoor_fair_attendee (fair_id);

COMMENT ON TABLE  shz.cms_outdoor_fair_attendee IS '户外招聘会签到人员表';
COMMENT ON COLUMN shz.cms_outdoor_fair_attendee.id            IS '主键';
COMMENT ON COLUMN shz.cms_outdoor_fair_attendee.fair_id       IS '招聘会ID';
COMMENT ON COLUMN shz.cms_outdoor_fair_attendee.name          IS '人员姓名';
COMMENT ON COLUMN shz.cms_outdoor_fair_attendee.phone         IS '手机号';
COMMENT ON COLUMN shz.cms_outdoor_fair_attendee.address       IS '住址';
COMMENT ON COLUMN shz.cms_outdoor_fair_attendee.check_in_time IS '签到时间';
COMMENT ON COLUMN shz.cms_outdoor_fair_attendee.del_flag      IS '删除标志（0存在 2删除）';

-- mock 5 条签到人员数据，归属 id=8 的招聘会
INSERT INTO shz.cms_outdoor_fair_attendee
    (fair_id, name, phone, address, check_in_time, create_by, create_time, del_flag)
VALUES
    (8, '张伟', '13800000001', '石河子市东城街道北一路上段', '2026-06-25 09:05:00', 'admin', now(), '0'),
    (8, '李娜', '13900000002', '石河子市新城街道西一路社区', '2026-06-25 09:12:00', 'admin', now(), '0'),
    (8, '王强', '13700000003', '石河子市红山街道三小区',     '2026-06-25 09:20:00', 'admin', now(), '0'),
    (8, '陈静', '13600000004', '石河子市向阳街道一社区',     '2026-06-25 09:31:00', 'admin', now(), '0'),
    (8, '刘洋', '13500000005', '石河子市老街街道五小区',     '2026-06-25 09:45:00', 'admin', now(), '0');
