From a129f555320b5c6685c8c84434c7fb82571ed518 Mon Sep 17 00:00:00 2001 From: chenziyi Date: Sat, 17 Aug 2024 15:53:30 +0800 Subject: [PATCH 1/2] feat: rearrange mentor application form --- metadata/tables.yaml | 137 +++++++++++++++--- .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 1 + 19 files changed, 153 insertions(+), 22 deletions(-) create mode 100644 migrations/1723102508087_alter_table_public_mentor_application_add_column_year/down.sql create mode 100644 migrations/1723102508087_alter_table_public_mentor_application_add_column_year/up.sql create mode 100644 migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/down.sql create mode 100644 migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/up.sql create mode 100644 migrations/1723107907984_alter_table_public_mentor_info_add_column_available/down.sql create mode 100644 migrations/1723107907984_alter_table_public_mentor_info_add_column_available/up.sql create mode 100644 migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/down.sql create mode 100644 migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/up.sql create mode 100644 migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/down.sql create mode 100644 migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/up.sql create mode 100644 migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/down.sql create mode 100644 migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/up.sql create mode 100644 migrations/1723724244348_create_table_public_freshman/down.sql create mode 100644 migrations/1723724244348_create_table_public_freshman/up.sql create mode 100644 migrations/1723724576894_alter_table_public_freshman_add_column_uuid/down.sql create mode 100644 migrations/1723724576894_alter_table_public_freshman_add_column_uuid/up.sql create mode 100644 migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/down.sql create mode 100644 migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/up.sql diff --git a/metadata/tables.yaml b/metadata/tables.yaml index f6bd619..23fc28c 100644 --- a/metadata/tables.yaml +++ b/metadata/tables.yaml @@ -2904,6 +2904,43 @@ columns: - name filter: {} +- table: + name: freshman + schema: public + insert_permissions: + - role: counselor + permission: + check: {} + columns: + - student_no + - realname + - year + - uuid + select_permissions: + - role: counselor + permission: + columns: + - year + - realname + - student_no + - uuid + filter: {} + allow_aggregations: true + update_permissions: + - role: counselor + permission: + columns: + - year + - realname + - student_no + - uuid + filter: {} + check: {} + delete_permissions: + - role: counselor + permission: + backend_only: false + filter: {} - table: name: honor_application schema: public @@ -3085,6 +3122,7 @@ - status - student_uuid - updated_at + - year - role: student permission: check: @@ -3094,6 +3132,7 @@ - mentor_uuid - statement - student_uuid + - year select_permissions: - role: counselor permission: @@ -3106,6 +3145,7 @@ - status - student_uuid - updated_at + - year filter: {} allow_aggregations: true - role: student @@ -3119,6 +3159,7 @@ - status - student_uuid - updated_at + - year filter: {} allow_aggregations: true - role: teacher @@ -3132,9 +3173,9 @@ - status - student_uuid - updated_at - filter: - mentor_uuid: - _eq: X-Hasura-User-Id + - year + filter: {} + allow_aggregations: true update_permissions: - role: counselor permission: @@ -3147,6 +3188,7 @@ - status - student_uuid - updated_at + - year filter: {} check: {} - role: student @@ -3208,6 +3250,7 @@ _eq: X-Hasura-User-Id columns: - available + - max_applicant - mentor_uuid select_permissions: - role: counselor @@ -3215,6 +3258,7 @@ columns: - available - created_at + - max_applicant - mentor_uuid - updated_at filter: {} @@ -3223,6 +3267,7 @@ columns: - available - created_at + - max_applicant - mentor_uuid - updated_at filter: {} @@ -3231,6 +3276,7 @@ columns: - available - created_at + - max_applicant - mentor_uuid - updated_at filter: @@ -3241,6 +3287,7 @@ permission: columns: - available + - max_applicant filter: mentor_uuid: _eq: X-Hasura-User-Id @@ -3259,82 +3306,98 @@ permission: check: {} columns: + - available + - max_applicants + - created_at + - updated_at + - mentor_uuid - achievement - background - - created_at - field - intro - - mentor_uuid - - updated_at - role: teacher permission: check: mentor_uuid: _eq: X-Hasura-User-Id columns: + - available + - max_applicants + - created_at + - updated_at + - mentor_uuid - achievement - background - - created_at - field - intro - - mentor_uuid - - updated_at select_permissions: - role: counselor permission: columns: + - available + - max_applicants + - created_at + - updated_at + - mentor_uuid - achievement - background - - created_at - field - intro - - mentor_uuid - - updated_at filter: {} allow_aggregations: true - role: student permission: columns: + - available + - max_applicants + - created_at + - updated_at + - mentor_uuid - achievement - background - field - intro - - mentor_uuid filter: {} + allow_aggregations: true - role: teacher permission: columns: + - available + - max_applicants + - created_at + - updated_at + - mentor_uuid - achievement - background - - created_at - field - intro - - mentor_uuid - - updated_at - filter: - mentor_uuid: - _eq: X-Hasura-User-Id + filter: {} + allow_aggregations: true update_permissions: - role: counselor permission: columns: + - available + - max_applicants + - created_at + - updated_at + - mentor_uuid - achievement - background - - created_at - field - intro - - mentor_uuid - - updated_at filter: {} check: {} - role: teacher permission: columns: - achievement + - available - background - created_at - field - intro + - max_applicants - updated_at filter: mentor_uuid: @@ -3435,6 +3498,36 @@ - start_D - start_E filter: {} + - role: student + permission: + columns: + - activateIn + - end_A + - end_B + - end_C + - end_D + - end_E + - start_A + - start_B + - start_C + - start_D + - start_E + filter: {} + - role: teacher + permission: + columns: + - activateIn + - end_A + - end_B + - end_C + - end_D + - end_E + - start_A + - start_B + - start_C + - start_D + - start_E + filter: {} update_permissions: - role: counselor permission: diff --git a/migrations/1723102508087_alter_table_public_mentor_application_add_column_year/down.sql b/migrations/1723102508087_alter_table_public_mentor_application_add_column_year/down.sql new file mode 100644 index 0000000..76eba4f --- /dev/null +++ b/migrations/1723102508087_alter_table_public_mentor_application_add_column_year/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."mentor_application" add column "year" integer +-- null; diff --git a/migrations/1723102508087_alter_table_public_mentor_application_add_column_year/up.sql b/migrations/1723102508087_alter_table_public_mentor_application_add_column_year/up.sql new file mode 100644 index 0000000..91409e2 --- /dev/null +++ b/migrations/1723102508087_alter_table_public_mentor_application_add_column_year/up.sql @@ -0,0 +1,2 @@ +alter table "public"."mentor_application" add column "year" integer + null; diff --git a/migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/down.sql b/migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/down.sql new file mode 100644 index 0000000..e6b06de --- /dev/null +++ b/migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."mentor_available" add column "max_applicant" integer +-- not null default '1'; diff --git a/migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/up.sql b/migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/up.sql new file mode 100644 index 0000000..08a3e59 --- /dev/null +++ b/migrations/1723105728516_alter_table_public_mentor_available_add_column_max_applicant/up.sql @@ -0,0 +1,2 @@ +alter table "public"."mentor_available" add column "max_applicant" integer + not null default '1'; diff --git a/migrations/1723107907984_alter_table_public_mentor_info_add_column_available/down.sql b/migrations/1723107907984_alter_table_public_mentor_info_add_column_available/down.sql new file mode 100644 index 0000000..942c85d --- /dev/null +++ b/migrations/1723107907984_alter_table_public_mentor_info_add_column_available/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."mentor_info" add column "available" boolean +-- not null default 'false'; diff --git a/migrations/1723107907984_alter_table_public_mentor_info_add_column_available/up.sql b/migrations/1723107907984_alter_table_public_mentor_info_add_column_available/up.sql new file mode 100644 index 0000000..9f00ed1 --- /dev/null +++ b/migrations/1723107907984_alter_table_public_mentor_info_add_column_available/up.sql @@ -0,0 +1,2 @@ +alter table "public"."mentor_info" add column "available" boolean + not null default 'false'; diff --git a/migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/down.sql b/migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/down.sql new file mode 100644 index 0000000..89092df --- /dev/null +++ b/migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."mentor_info" add column "max_applicants" integer +-- not null default '1'; diff --git a/migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/up.sql b/migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/up.sql new file mode 100644 index 0000000..496cc62 --- /dev/null +++ b/migrations/1723107951030_alter_table_public_mentor_info_add_column_max_applicants/up.sql @@ -0,0 +1,2 @@ +alter table "public"."mentor_info" add column "max_applicants" integer + not null default '1'; diff --git a/migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/down.sql b/migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/down.sql new file mode 100644 index 0000000..92056a3 --- /dev/null +++ b/migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/down.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."mentor_application" ALTER COLUMN "year" drop default; diff --git a/migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/up.sql b/migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/up.sql new file mode 100644 index 0000000..cdf3b38 --- /dev/null +++ b/migrations/1723208713299_alter_table_public_mentor_application_alter_column_year/up.sql @@ -0,0 +1 @@ +alter table "public"."mentor_application" alter column "year" set default '2023'; diff --git a/migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/down.sql b/migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/down.sql new file mode 100644 index 0000000..5e11f6c --- /dev/null +++ b/migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/down.sql @@ -0,0 +1 @@ +alter table "public"."mentor_application" alter column "year" drop not null; diff --git a/migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/up.sql b/migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/up.sql new file mode 100644 index 0000000..163faf2 --- /dev/null +++ b/migrations/1723208779923_alter_table_public_mentor_application_alter_column_year/up.sql @@ -0,0 +1 @@ +alter table "public"."mentor_application" alter column "year" set not null; diff --git a/migrations/1723724244348_create_table_public_freshman/down.sql b/migrations/1723724244348_create_table_public_freshman/down.sql new file mode 100644 index 0000000..8827966 --- /dev/null +++ b/migrations/1723724244348_create_table_public_freshman/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."freshman"; diff --git a/migrations/1723724244348_create_table_public_freshman/up.sql b/migrations/1723724244348_create_table_public_freshman/up.sql new file mode 100644 index 0000000..eb50396 --- /dev/null +++ b/migrations/1723724244348_create_table_public_freshman/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."freshman" ("student_no" text NOT NULL, "realname" text NOT NULL, "year" int4 NOT NULL, PRIMARY KEY ("student_no") , UNIQUE ("student_no")); diff --git a/migrations/1723724576894_alter_table_public_freshman_add_column_uuid/down.sql b/migrations/1723724576894_alter_table_public_freshman_add_column_uuid/down.sql new file mode 100644 index 0000000..432c508 --- /dev/null +++ b/migrations/1723724576894_alter_table_public_freshman_add_column_uuid/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."freshman" add column "uuid" uuid +-- null unique; diff --git a/migrations/1723724576894_alter_table_public_freshman_add_column_uuid/up.sql b/migrations/1723724576894_alter_table_public_freshman_add_column_uuid/up.sql new file mode 100644 index 0000000..b0836df --- /dev/null +++ b/migrations/1723724576894_alter_table_public_freshman_add_column_uuid/up.sql @@ -0,0 +1,2 @@ +alter table "public"."freshman" add column "uuid" uuid + null unique; diff --git a/migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/down.sql b/migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/down.sql new file mode 100644 index 0000000..79cf6b9 --- /dev/null +++ b/migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/down.sql @@ -0,0 +1 @@ +alter table "public"."mentor_info" alter column "max_applicants" set default '1'; diff --git a/migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/up.sql b/migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/up.sql new file mode 100644 index 0000000..dcebccd --- /dev/null +++ b/migrations/1723874910629_alter_table_public_mentor_info_alter_column_max_applicants/up.sql @@ -0,0 +1 @@ +alter table "public"."mentor_info" alter column "max_applicants" set default '5'; From 968599a27e3733488dfeb5227f8848c6c3544b4a Mon Sep 17 00:00:00 2001 From: chenziyi Date: Sat, 17 Aug 2024 16:06:16 +0800 Subject: [PATCH 2/2] fix: set nullable --- .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + 8 files changed, 8 insertions(+) create mode 100644 migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/down.sql create mode 100644 migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/up.sql create mode 100644 migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/down.sql create mode 100644 migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/up.sql create mode 100644 migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/down.sql create mode 100644 migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/up.sql create mode 100644 migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/down.sql create mode 100644 migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/up.sql diff --git a/migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/down.sql b/migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/down.sql new file mode 100644 index 0000000..efdc3f5 --- /dev/null +++ b/migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/down.sql @@ -0,0 +1 @@ +alter table "public"."mentor_info" alter column "available" set not null; diff --git a/migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/up.sql b/migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/up.sql new file mode 100644 index 0000000..92b66a6 --- /dev/null +++ b/migrations/1723881817713_alter_table_public_mentor_info_alter_column_available/up.sql @@ -0,0 +1 @@ +alter table "public"."mentor_info" alter column "available" drop not null; diff --git a/migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/down.sql b/migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/down.sql new file mode 100644 index 0000000..c0cfaae --- /dev/null +++ b/migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/down.sql @@ -0,0 +1 @@ +alter table "public"."mentor_info" alter column "max_applicants" set not null; diff --git a/migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/up.sql b/migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/up.sql new file mode 100644 index 0000000..97a0e8e --- /dev/null +++ b/migrations/1723881829180_alter_table_public_mentor_info_alter_column_max_applicants/up.sql @@ -0,0 +1 @@ +alter table "public"."mentor_info" alter column "max_applicants" drop not null; diff --git a/migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/down.sql b/migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/down.sql new file mode 100644 index 0000000..ddfac35 --- /dev/null +++ b/migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/down.sql @@ -0,0 +1 @@ +alter table "public"."mentor_available" alter column "max_applicant" set not null; diff --git a/migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/up.sql b/migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/up.sql new file mode 100644 index 0000000..641926d --- /dev/null +++ b/migrations/1723881929640_alter_table_public_mentor_available_alter_column_max_applicant/up.sql @@ -0,0 +1 @@ +alter table "public"."mentor_available" alter column "max_applicant" drop not null; diff --git a/migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/down.sql b/migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/down.sql new file mode 100644 index 0000000..163faf2 --- /dev/null +++ b/migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/down.sql @@ -0,0 +1 @@ +alter table "public"."mentor_application" alter column "year" set not null; diff --git a/migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/up.sql b/migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/up.sql new file mode 100644 index 0000000..5e11f6c --- /dev/null +++ b/migrations/1723881945772_alter_table_public_mentor_application_alter_column_year/up.sql @@ -0,0 +1 @@ +alter table "public"."mentor_application" alter column "year" drop not null;