-- 移动端求职者消息接收设置。
-- 瀚高 / PostgreSQL 兼容；重复执行安全。表放在 shz schema，应用通过 search_path 访问。

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

CREATE TABLE IF NOT EXISTS shz.app_user_notice_setting (
    id                            BIGINT      NOT NULL DEFAULT nextval('shz.app_user_notice_setting_id_seq'::regclass) PRIMARY KEY,
    user_id                       BIGINT      NOT NULL,
    job_update_enabled            BOOLEAN     NOT NULL DEFAULT TRUE,
    appointment_reminder_enabled  BOOLEAN     NOT NULL DEFAULT TRUE,
    system_notification_enabled   BOOLEAN     NOT NULL DEFAULT TRUE,
    interview_notification_enabled BOOLEAN    NOT NULL DEFAULT TRUE,
    create_by                     VARCHAR(64) DEFAULT '',
    create_time                   TIMESTAMP(0),
    update_by                     VARCHAR(64) DEFAULT '',
    update_time                   TIMESTAMP(0),
    remark                        VARCHAR(500),
    del_flag                      CHAR(1)     DEFAULT '0'
);

CREATE UNIQUE INDEX IF NOT EXISTS uk_app_user_notice_setting_user_id
    ON shz.app_user_notice_setting (user_id);

COMMENT ON TABLE shz.app_user_notice_setting IS '移动端求职者消息接收设置';
COMMENT ON COLUMN shz.app_user_notice_setting.user_id IS 'APP 用户 ID，每用户唯一';
COMMENT ON COLUMN shz.app_user_notice_setting.job_update_enabled IS '是否接收职位上新通知';
COMMENT ON COLUMN shz.app_user_notice_setting.appointment_reminder_enabled IS '是否接收招聘会预约提醒';
COMMENT ON COLUMN shz.app_user_notice_setting.system_notification_enabled IS '是否接收系统通知';
COMMENT ON COLUMN shz.app_user_notice_setting.interview_notification_enabled IS '是否接收面试通知';
