LasTres/dbicdh/PostgreSQL/upgrade/4-5/001-auto.sql

38 lines
1.1 KiB
PL/PgSQL

-- Convert schema '/home/sergio/LasTres/script/../dbicdh/_source/deploy/4/001-auto.yml' to '/home/sergio/LasTres/script/../dbicdh/_source/deploy/5/001-auto.yml':;
;
BEGIN;
;
CREATE TABLE "player_pjs_flags" (
"name" text NOT NULL,
"owner" uuid NOT NULL,
PRIMARY KEY ("name", "owner")
);
CREATE INDEX "player_pjs_flags_idx_owner" on "player_pjs_flags" ("owner");
CREATE INDEX "index_flag" on "player_pjs_flags" ("owner", "name");
;
CREATE TABLE "player_pjs_log" (
"uuid" uuid NOT NULL,
"content" jsonb NOT NULL,
"owner" uuid NOT NULL,
"date" timestamp DEFAULT NOW() NOT NULL,
PRIMARY KEY ("uuid")
);
CREATE INDEX "player_pjs_log_idx_owner" on "player_pjs_log" ("owner");
CREATE INDEX "index_log" on "player_pjs_log" ("owner", "date");
;
ALTER TABLE "player_pjs_flags" ADD CONSTRAINT "player_pjs_flags_fk_owner" FOREIGN KEY ("owner")
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
;
ALTER TABLE "player_pjs_log" ADD CONSTRAINT "player_pjs_log_fk_owner" FOREIGN KEY ("owner")
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
;
COMMIT;