From 48adf243492eb8d6acd72867900a9eda5d6b6fc2 Mon Sep 17 00:00:00 2001 From: xiangmy21 <2248278431@qq.com> Date: Mon, 18 Mar 2024 01:54:04 +0800 Subject: [PATCH] feat(code): add contest_team_code & contest_team_player --- metadata/tables.yaml | 276 ++++++++++++++++++ .../down.sql | 1 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 5 + .../down.sql | 1 + .../up.sql | 5 + .../down.sql | 1 + .../up.sql | 5 + 13 files changed, 301 insertions(+) create mode 100644 migrations/1710695701056_create_table_public_contest_team_code/down.sql create mode 100644 migrations/1710695701056_create_table_public_contest_team_code/up.sql create mode 100644 migrations/1710695749035_alter_table_public_contest_team_code_update_comment/down.sql create mode 100644 migrations/1710695749035_alter_table_public_contest_team_code_update_comment/up.sql create mode 100644 migrations/1710696330148_create_table_public_contest_team_player/down.sql create mode 100644 migrations/1710696330148_create_table_public_contest_team_player/up.sql create mode 100644 migrations/1710696541220_set_fk_public_contest_team_player_code_id/down.sql create mode 100644 migrations/1710696541220_set_fk_public_contest_team_player_code_id/up.sql create mode 100644 migrations/1710696708882_set_fk_public_contest_team_code_team_id/down.sql create mode 100644 migrations/1710696708882_set_fk_public_contest_team_code_team_id/up.sql create mode 100644 migrations/1710696941945_set_fk_public_contest_team_player_team_id/down.sql create mode 100644 migrations/1710696941945_set_fk_public_contest_team_player_team_id/up.sql diff --git a/metadata/tables.yaml b/metadata/tables.yaml index c1801eb..ccb7420 100644 --- a/metadata/tables.yaml +++ b/metadata/tables.yaml @@ -541,6 +541,13 @@ using: foreign_key_constraint_on: team_leader_uuid array_relationships: + - name: contest_team_codes + using: + foreign_key_constraint_on: + column: team_id + table: + name: contest_team_code + schema: public - name: contest_team_members using: foreign_key_constraint_on: @@ -548,6 +555,13 @@ table: name: contest_team_member schema: public + - name: contest_team_players + using: + foreign_key_constraint_on: + column: team_id + table: + name: contest_team_player + schema: public insert_permissions: - role: counselor permission: @@ -666,6 +680,153 @@ permission: backend_only: false filter: {} +- table: + name: contest_team_code + schema: public + insert_permissions: + - role: counselor + permission: + check: {} + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + - role: student + permission: + check: {} + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + - role: teacher + permission: + check: {} + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + - role: user + permission: + check: {} + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + select_permissions: + - role: counselor + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + - role: student + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + - role: teacher + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + - role: user + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + update_permissions: + - role: counselor + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + check: {} + - role: student + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + check: {} + - role: teacher + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + check: {} + - role: user + permission: + columns: + - code_id + - code_name + - compile_status + - created_at + - language + - team_id + filter: {} + check: {} + delete_permissions: + - role: counselor + permission: + backend_only: false + filter: {} + - role: student + permission: + backend_only: false + filter: {} + - role: teacher + permission: + backend_only: false + filter: {} + - role: user + permission: + backend_only: false + filter: {} - table: name: contest_team_member schema: public @@ -732,6 +893,121 @@ permission: backend_only: false filter: {} +- table: + name: contest_team_player + schema: public + object_relationships: + - name: player_code + using: + foreign_key_constraint_on: code_id + insert_permissions: + - role: counselor + permission: + check: {} + columns: + - team_id + - player + - code_id + - role: student + permission: + check: {} + columns: + - team_id + - player + - code_id + - role: teacher + permission: + check: {} + columns: + - team_id + - player + - code_id + - role: user + permission: + check: {} + columns: + - team_id + - player + - code_id + select_permissions: + - role: counselor + permission: + columns: + - team_id + - player + - code_id + filter: {} + - role: student + permission: + columns: + - team_id + - player + - code_id + filter: {} + - role: teacher + permission: + columns: + - team_id + - player + - code_id + filter: {} + - role: user + permission: + columns: + - team_id + - player + - code_id + filter: {} + update_permissions: + - role: counselor + permission: + columns: + - team_id + - player + - code_id + filter: {} + check: {} + - role: student + permission: + columns: + - team_id + - player + - code_id + filter: {} + check: {} + - role: teacher + permission: + columns: + - team_id + - player + - code_id + filter: {} + check: {} + - role: user + permission: + columns: + - team_id + - player + - code_id + filter: {} + check: {} + delete_permissions: + - role: counselor + permission: + backend_only: false + filter: {} + - role: student + permission: + backend_only: false + filter: {} + - role: teacher + permission: + backend_only: false + filter: {} + - role: user + permission: + backend_only: false + filter: {} - table: name: honor_application schema: public diff --git a/migrations/1710695701056_create_table_public_contest_team_code/down.sql b/migrations/1710695701056_create_table_public_contest_team_code/down.sql new file mode 100644 index 0000000..709c3ad --- /dev/null +++ b/migrations/1710695701056_create_table_public_contest_team_code/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."contest_team_code"; diff --git a/migrations/1710695701056_create_table_public_contest_team_code/up.sql b/migrations/1710695701056_create_table_public_contest_team_code/up.sql new file mode 100644 index 0000000..eb80d27 --- /dev/null +++ b/migrations/1710695701056_create_table_public_contest_team_code/up.sql @@ -0,0 +1,2 @@ +CREATE TABLE "public"."contest_team_code" ("team_id" uuid NOT NULL, "code_id" uuid NOT NULL DEFAULT gen_random_uuid(), "code_name" text NOT NULL, "language" text NOT NULL, "compile_status" text NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("code_id") , UNIQUE ("code_id"));COMMENT ON TABLE "public"."contest_team_code" IS E'记录每个team上传的所有code'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/migrations/1710695749035_alter_table_public_contest_team_code_update_comment/down.sql b/migrations/1710695749035_alter_table_public_contest_team_code_update_comment/down.sql new file mode 100644 index 0000000..4fc0a1b --- /dev/null +++ b/migrations/1710695749035_alter_table_public_contest_team_code_update_comment/down.sql @@ -0,0 +1 @@ +comment on table "public"."contest_team_code" is NULL; diff --git a/migrations/1710695749035_alter_table_public_contest_team_code_update_comment/up.sql b/migrations/1710695749035_alter_table_public_contest_team_code_update_comment/up.sql new file mode 100644 index 0000000..4460cfd --- /dev/null +++ b/migrations/1710695749035_alter_table_public_contest_team_code_update_comment/up.sql @@ -0,0 +1 @@ +comment on table "public"."contest_team_code" is E'记录每个team上传的所有code,角色应从上传的code中选择一份。'; diff --git a/migrations/1710696330148_create_table_public_contest_team_player/down.sql b/migrations/1710696330148_create_table_public_contest_team_player/down.sql new file mode 100644 index 0000000..865e57c --- /dev/null +++ b/migrations/1710696330148_create_table_public_contest_team_player/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."contest_team_player"; diff --git a/migrations/1710696330148_create_table_public_contest_team_player/up.sql b/migrations/1710696330148_create_table_public_contest_team_player/up.sql new file mode 100644 index 0000000..d61a17d --- /dev/null +++ b/migrations/1710696330148_create_table_public_contest_team_player/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."contest_team_player" ("team_id" uuid NOT NULL, "player" text NOT NULL, "code_id" uuid, PRIMARY KEY ("team_id","player") );COMMENT ON TABLE "public"."contest_team_player" IS E'记录每个team的每个player选择了哪份code'; diff --git a/migrations/1710696541220_set_fk_public_contest_team_player_code_id/down.sql b/migrations/1710696541220_set_fk_public_contest_team_player_code_id/down.sql new file mode 100644 index 0000000..c19f807 --- /dev/null +++ b/migrations/1710696541220_set_fk_public_contest_team_player_code_id/down.sql @@ -0,0 +1 @@ +alter table "public"."contest_team_player" drop constraint "contest_team_player_code_id_fkey"; diff --git a/migrations/1710696541220_set_fk_public_contest_team_player_code_id/up.sql b/migrations/1710696541220_set_fk_public_contest_team_player_code_id/up.sql new file mode 100644 index 0000000..f8a80bd --- /dev/null +++ b/migrations/1710696541220_set_fk_public_contest_team_player_code_id/up.sql @@ -0,0 +1,5 @@ +alter table "public"."contest_team_player" + add constraint "contest_team_player_code_id_fkey" + foreign key ("code_id") + references "public"."contest_team_code" + ("code_id") on update restrict on delete set null; diff --git a/migrations/1710696708882_set_fk_public_contest_team_code_team_id/down.sql b/migrations/1710696708882_set_fk_public_contest_team_code_team_id/down.sql new file mode 100644 index 0000000..0f8ef10 --- /dev/null +++ b/migrations/1710696708882_set_fk_public_contest_team_code_team_id/down.sql @@ -0,0 +1 @@ +alter table "public"."contest_team_code" drop constraint "contest_team_code_team_id_fkey"; diff --git a/migrations/1710696708882_set_fk_public_contest_team_code_team_id/up.sql b/migrations/1710696708882_set_fk_public_contest_team_code_team_id/up.sql new file mode 100644 index 0000000..f9f9cb1 --- /dev/null +++ b/migrations/1710696708882_set_fk_public_contest_team_code_team_id/up.sql @@ -0,0 +1,5 @@ +alter table "public"."contest_team_code" + add constraint "contest_team_code_team_id_fkey" + foreign key ("team_id") + references "public"."contest_team" + ("team_id") on update restrict on delete cascade; diff --git a/migrations/1710696941945_set_fk_public_contest_team_player_team_id/down.sql b/migrations/1710696941945_set_fk_public_contest_team_player_team_id/down.sql new file mode 100644 index 0000000..72b5d45 --- /dev/null +++ b/migrations/1710696941945_set_fk_public_contest_team_player_team_id/down.sql @@ -0,0 +1 @@ +alter table "public"."contest_team_player" drop constraint "contest_team_player_team_id_fkey"; diff --git a/migrations/1710696941945_set_fk_public_contest_team_player_team_id/up.sql b/migrations/1710696941945_set_fk_public_contest_team_player_team_id/up.sql new file mode 100644 index 0000000..a44e6cc --- /dev/null +++ b/migrations/1710696941945_set_fk_public_contest_team_player_team_id/up.sql @@ -0,0 +1,5 @@ +alter table "public"."contest_team_player" + add constraint "contest_team_player_team_id_fkey" + foreign key ("team_id") + references "public"."contest_team" + ("team_id") on update restrict on delete cascade;