-- 场地展位图模板：只保存固定布局，不保存企业、预定状态或预定记录。
-- 瀚高数据库 / PostgreSQL 兼容；可重复执行。

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

CREATE TABLE IF NOT EXISTS "cms_venue_booth" (
    "id" BIGINT NOT NULL DEFAULT nextval('"cms_venue_booth_id_seq"') PRIMARY KEY,
    "venue_id" BIGINT NOT NULL,
    "booth_number" VARCHAR(50) NOT NULL,
    "position_x" INTEGER NOT NULL DEFAULT 0,
    "position_y" INTEGER NOT NULL DEFAULT 0,
    "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_venue_booth" IS '场地展位图模板';
COMMENT ON COLUMN "cms_venue_booth"."venue_id" IS '场地ID';
COMMENT ON COLUMN "cms_venue_booth"."booth_number" IS '展位号';
COMMENT ON COLUMN "cms_venue_booth"."position_x" IS 'X坐标';
COMMENT ON COLUMN "cms_venue_booth"."position_y" IS 'Y坐标';

CREATE UNIQUE INDEX IF NOT EXISTS "uk_cms_venue_booth_number" ON "cms_venue_booth" ("venue_id", "booth_number");
CREATE INDEX IF NOT EXISTS "idx_cms_venue_booth_venue" ON "cms_venue_booth" ("venue_id");
