From d1c3051a5e4817877cba200d6c899b103cb0d934 Mon Sep 17 00:00:00 2001 From: Tau Date: Sun, 26 May 2019 20:05:13 -0400 Subject: [PATCH] idz: Add initial team tables --- schema/init/idz.sql | 51 +++++++++++++++++++++++++++ schema/init/meta.sql | 2 +- schema/migrate/M0003-idz-add-team.sql | 42 ++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 schema/migrate/M0003-idz-add-team.sql diff --git a/schema/init/idz.sql b/schema/init/idz.sql index 2a365f4..8a3f029 100644 --- a/schema/init/idz.sql +++ b/schema/init/idz.sql @@ -190,3 +190,54 @@ create table "idz"."unlocks" ( "music" integer not null, "last_mileage_reward" integer not null ); + +create table "idz"."team" ( + "id" bigint primary key not null, + "ext_id" integer not null, + "name" text not null, + "name_bg" smallint not null, + "name_fx" smallint not null, + "register_time" timestamp not null, + constraint "team_uq" unique ("ext_id") +); + +create table "idz"."team" ( + "id" bigint primary key not null, + "ext_id" integer not null, + "name" text not null, + "name_bg" smallint not null, + "name_fx" smallint not null, + "register_time" timestamp not null, + constraint "team_uq" unique ("ext_id") +); + +create table "idz"."team_auto" ( + "id" bigint primary key not null + references "idz"."team"("id") + on delete cascade, + "serial_no" smallint not null, + "name_idx" smallint not null, + constraint "team_auto_uq" unique ("serial_no", "name_idx") +); + +create table "idz"."team_member" ( + "id" bigint primary key not null + references "idz"."profile"("id") + on delete cascade, + "team_id" bigint not null + references "idz"."team"("id") + on delete cascade, + "join_time" timestamp not null, + "leader" boolean not null +); + +create table "idz"."team_reservation" ( + "id" bigint primary key not null + references "aime"."player"("id") + on delete cascade, + "team_id" bigint not null + references "idz"."team"("id") + on delete cascade, + "join_time" timestamp not null, + "leader" boolean not null +); diff --git a/schema/init/meta.sql b/schema/init/meta.sql index 800c80b..4282f71 100644 --- a/schema/init/meta.sql +++ b/schema/init/meta.sql @@ -1,2 +1,2 @@ create table "meta" ("schemaver" integer not null); -insert into "meta" values (2); +insert into "meta" values (3); diff --git a/schema/migrate/M0003-idz-add-team.sql b/schema/migrate/M0003-idz-add-team.sql new file mode 100644 index 0000000..8b49b3b --- /dev/null +++ b/schema/migrate/M0003-idz-add-team.sql @@ -0,0 +1,42 @@ +create table "idz"."team" ( + "id" bigint primary key not null, + "ext_id" integer not null, + "name" text not null, + "name_bg" smallint not null, + "name_fx" smallint not null, + "register_time" timestamp not null, + constraint "team_uq" unique ("ext_id") +); + +create table "idz"."team_auto" ( + "id" bigint primary key not null + references "idz"."team"("id") + on delete cascade, + "serial_no" smallint not null, + "name_idx" smallint not null, + constraint "team_auto_uq" unique ("serial_no", "name_idx") +); + +create table "idz"."team_member" ( + "id" bigint primary key not null + references "idz"."profile"("id") + on delete cascade, + "team_id" bigint not null + references "idz"."team"("id") + on delete cascade, + "join_time" timestamp not null, + "leader" boolean not null +); + +create table "idz"."team_reservation" ( + "id" bigint primary key not null + references "aime"."player"("id") + on delete cascade, + "team_id" bigint not null + references "idz"."team"("id") + on delete cascade, + "join_time" timestamp not null, + "leader" boolean not null +); + +update "meta" set "schemaver" = 2;