-- 户外招聘会表
-- 瀚高数据库 / PostgreSQL 兼容

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

CREATE TABLE IF NOT EXISTS "cms_outdoor_fair" (
    "id" BIGINT NOT NULL DEFAULT nextval('"cms_outdoor_fair_id_seq"') PRIMARY KEY,
    "title" VARCHAR(200) NOT NULL,
    "host_unit" VARCHAR(200) NOT NULL,
    "fair_type" VARCHAR(50) NOT NULL,
    "region" VARCHAR(100) NOT NULL,
    "venue_id" BIGINT,
    "venue_name" VARCHAR(200),
    "address" VARCHAR(500) NOT NULL,
    "booth_count" INTEGER NOT NULL DEFAULT 0,
    "hold_time" TIMESTAMP(0) NOT NULL,
    "end_time" TIMESTAMP(0) NOT NULL,
    "apply_start_time" TIMESTAMP(0) NOT NULL,
    "apply_end_time" TIMESTAMP(0) NOT NULL,
    "online_apply" BOOLEAN NOT NULL DEFAULT FALSE,
    "photo_url" VARCHAR(500),
    "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'
);

COMMENT ON TABLE "cms_outdoor_fair" IS '户外招聘会表';
COMMENT ON COLUMN "cms_outdoor_fair"."id" IS '主键ID';
COMMENT ON COLUMN "cms_outdoor_fair"."title" IS '招聘会标题';
COMMENT ON COLUMN "cms_outdoor_fair"."host_unit" IS '举办单位';
COMMENT ON COLUMN "cms_outdoor_fair"."fair_type" IS '招聘会类型';
COMMENT ON COLUMN "cms_outdoor_fair"."region" IS '举办区域';
COMMENT ON COLUMN "cms_outdoor_fair"."venue_id" IS '绑定场地ID';
COMMENT ON COLUMN "cms_outdoor_fair"."venue_name" IS '绑定场地';
COMMENT ON COLUMN "cms_outdoor_fair"."address" IS '举办地址';
COMMENT ON COLUMN "cms_outdoor_fair"."booth_count" IS '展位数量';
COMMENT ON COLUMN "cms_outdoor_fair"."hold_time" IS '举办时间';
COMMENT ON COLUMN "cms_outdoor_fair"."end_time" IS '截止时间';
COMMENT ON COLUMN "cms_outdoor_fair"."apply_start_time" IS '开放申请时间';
COMMENT ON COLUMN "cms_outdoor_fair"."apply_end_time" IS '截止申请时间';
COMMENT ON COLUMN "cms_outdoor_fair"."online_apply" IS '是否开启线上申请';
COMMENT ON COLUMN "cms_outdoor_fair"."photo_url" IS '招聘会照片';
COMMENT ON COLUMN "cms_outdoor_fair"."del_flag" IS '删除标志（0代表存在 2代表删除）';

CREATE INDEX IF NOT EXISTS "idx_cms_outdoor_fair_title" ON "cms_outdoor_fair" ("title");
CREATE INDEX IF NOT EXISTS "idx_cms_outdoor_fair_host_unit" ON "cms_outdoor_fair" ("host_unit");
CREATE INDEX IF NOT EXISTS "idx_cms_outdoor_fair_type" ON "cms_outdoor_fair" ("fair_type");
CREATE INDEX IF NOT EXISTS "idx_cms_outdoor_fair_venue_id" ON "cms_outdoor_fair" ("venue_id");
CREATE INDEX IF NOT EXISTS "idx_cms_outdoor_fair_hold_time" ON "cms_outdoor_fair" ("hold_time");
CREATE INDEX IF NOT EXISTS "idx_cms_outdoor_fair_del_flag" ON "cms_outdoor_fair" ("del_flag");
