Skip to content

Commit

Permalink
Merge pull request #155 from FranGuam/dev
Browse files Browse the repository at this point in the history
feat: add table `contest_round` & `contest_map`
  • Loading branch information
xiangmy21 authored Mar 24, 2024
2 parents 9acaaa2 + c11551e commit fdd693e
Show file tree
Hide file tree
Showing 25 changed files with 575 additions and 28 deletions.
508 changes: 480 additions & 28 deletions metadata/tables.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."contest_room_team" add column "team_label" text
-- not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."contest_room_team" add column "team_label" text
not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."contest_room_team" alter column "players" drop not null;
alter table "public"."contest_room_team" add column "players" text;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."contest_room_team" drop column "players" cascade;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."contest_room_team" add column "player_roles" text
-- null default '{}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."contest_room_team" add column "player_roles" text
null default '{}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."contest_room_team" add column "player_codes" text
-- null default '{}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."contest_room_team" add column "player_codes" text
null default '{}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."contest_room" alter column "status" set default 'false';
ALTER TABLE "public"."contest_room" ALTER COLUMN "status" TYPE boolean;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "public"."contest_room" ALTER COLUMN "status" TYPE text;
ALTER TABLE "public"."contest_room" ALTER COLUMN "status" drop default;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "public"."contest_round";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE TABLE "public"."contest_round" ("contest_id" uuid NOT NULL, "round_id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" text NOT NULL, "maps" text NOT NULL DEFAULT '[]', PRIMARY KEY ("round_id") , FOREIGN KEY ("contest_id") REFERENCES "public"."contest"("id") ON UPDATE restrict ON DELETE cascade, UNIQUE ("round_id"));COMMENT ON TABLE "public"."contest_round" IS E'正式比赛的每轮(初赛、决赛)信息';
CREATE EXTENSION IF NOT EXISTS pgcrypto;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."contest_room" add column "round_id" uuid
-- null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."contest_room" add column "round_id" uuid
null;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."contest_room" drop constraint "contest_room_round_id_fkey";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."contest_room"
add constraint "contest_room_round_id_fkey"
foreign key ("round_id")
references "public"."contest_round"
("round_id") on update restrict on delete cascade;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "public"."contest_map";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE TABLE "public"."contest_map" ("contest_id" uuid NOT NULL, "map_id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" text NOT NULL, "filename" text NOT NULL, "team_labels" text NOT NULL DEFAULT '[]', PRIMARY KEY ("map_id") , FOREIGN KEY ("contest_id") REFERENCES "public"."contest"("id") ON UPDATE restrict ON DELETE cascade, UNIQUE ("map_id"));COMMENT ON TABLE "public"."contest_map" IS E'比赛用到的地图(文件)';
CREATE EXTENSION IF NOT EXISTS pgcrypto;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."contest_room" add column "map_id" uuid
-- null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."contest_room" add column "map_id" uuid
null;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."contest_room" drop constraint "contest_room_map_id_fkey";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."contest_room"
add constraint "contest_room_map_id_fkey"
foreign key ("map_id")
references "public"."contest_map"
("map_id") on update restrict on delete cascade;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."contest_room" add column "updated_at" timestamptz
-- null default now();
--
-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
-- RETURNS TRIGGER AS $$
-- DECLARE
-- _new record;
-- BEGIN
-- _new := NEW;
-- _new."updated_at" = NOW();
-- RETURN _new;
-- END;
-- $$ LANGUAGE plpgsql;
-- CREATE TRIGGER "set_public_contest_room_updated_at"
-- BEFORE UPDATE ON "public"."contest_room"
-- FOR EACH ROW
-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
-- COMMENT ON TRIGGER "set_public_contest_room_updated_at" ON "public"."contest_room"
-- IS 'trigger to set value of column "updated_at" to current timestamp on row update';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
alter table "public"."contest_room" add column "updated_at" timestamptz
null default now();

CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_contest_room_updated_at"
BEFORE UPDATE ON "public"."contest_room"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_contest_room_updated_at" ON "public"."contest_room"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

0 comments on commit fdd693e

Please sign in to comment.