From 6b7b5e8318f3ba1081e28ba141351d46dedc9dd0 Mon Sep 17 00:00:00 2001 From: zzdhyb <139191187+zzdhybthu@users.noreply.github.com> Date: Mon, 27 May 2024 16:53:10 +0800 Subject: [PATCH] fix: delete comment_comment table and and father relationship (#182) --- metadata/tables.yaml | 205 +++--------------- .../down.sql | 3 + .../up.sql | 1 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 5 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + 11 files changed, 48 insertions(+), 177 deletions(-) create mode 100644 migrations/1716721070980_drop_table_public_course_comment_comment/down.sql create mode 100644 migrations/1716721070980_drop_table_public_course_comment_comment/up.sql create mode 100644 migrations/1716721863423_alter_table_public_course_comment_add_column_parent_uuid/down.sql create mode 100644 migrations/1716721863423_alter_table_public_course_comment_add_column_parent_uuid/up.sql create mode 100644 migrations/1716721897201_set_fk_public_course_comment_parent_uuid/down.sql create mode 100644 migrations/1716721897201_set_fk_public_course_comment_parent_uuid/up.sql create mode 100644 migrations/1716723050648_rename_table_public_course_comment_star/down.sql create mode 100644 migrations/1716723050648_rename_table_public_course_comment_star/up.sql create mode 100644 migrations/1716723060912_rename_table_public_course_comment_like/down.sql create mode 100644 migrations/1716723060912_rename_table_public_course_comment_like/up.sql diff --git a/metadata/tables.yaml b/metadata/tables.yaml index bde7e4f..d11c04b 100644 --- a/metadata/tables.yaml +++ b/metadata/tables.yaml @@ -2297,40 +2297,22 @@ - name: course using: foreign_key_constraint_on: course_id + - name: course_comment_parent + using: + foreign_key_constraint_on: parent_uuid - name: user using: foreign_key_constraint_on: user_uuid - array_relationships: - - name: course_comment_comments - using: - foreign_key_constraint_on: - column: comment_uuid - table: - name: course_comment_comment - schema: public - - name: course_comment_likes - using: - foreign_key_constraint_on: - column: comment_uuid - table: - name: course_comment_like - schema: public - - name: course_comment_stars - using: - foreign_key_constraint_on: - column: comment_uuid - table: - name: course_comment_star - schema: public insert_permissions: - role: counselor permission: check: {} columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid - role: student @@ -2338,9 +2320,10 @@ check: {} columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid - role: teacher @@ -2348,9 +2331,10 @@ check: {} columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid select_permissions: @@ -2358,9 +2342,10 @@ permission: columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid filter: {} @@ -2369,9 +2354,10 @@ permission: columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid filter: {} @@ -2382,6 +2368,7 @@ - comment - course_id - created_at + - parent_uuid - updated_at - user_uuid - uuid @@ -2392,9 +2379,10 @@ permission: columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid filter: {} @@ -2403,9 +2391,10 @@ permission: columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid filter: {} @@ -2414,9 +2403,10 @@ permission: columns: - comment - - course_id - created_at - updated_at + - course_id + - parent_uuid - user_uuid - uuid filter: {} @@ -2435,117 +2425,7 @@ backend_only: false filter: {} - table: - name: course_comment_comment - schema: public - object_relationships: - - name: course_comment - using: - foreign_key_constraint_on: comment_uuid - - name: user - using: - foreign_key_constraint_on: user_uuid - insert_permissions: - - role: counselor - permission: - check: {} - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - - role: student - permission: - check: {} - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - - role: teacher - permission: - check: {} - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - select_permissions: - - role: counselor - permission: - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - filter: {} - - role: student - permission: - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - filter: {} - - role: teacher - permission: - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - filter: {} - update_permissions: - - role: counselor - permission: - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - filter: {} - check: {} - - role: student - permission: - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - filter: {} - check: {} - - role: teacher - permission: - columns: - - comment - - create_at - - update_at - - comment_uuid - - user_uuid - 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: {} -- table: - name: course_comment_like + name: course_comment_likes schema: public object_relationships: - name: course_comment @@ -2580,18 +2460,21 @@ - comment_uuid - user_uuid filter: {} + allow_aggregations: true - role: student permission: columns: - comment_uuid - user_uuid filter: {} + allow_aggregations: true - role: teacher permission: columns: - comment_uuid - user_uuid filter: {} + allow_aggregations: true update_permissions: - role: counselor permission: @@ -2628,7 +2511,7 @@ backend_only: false filter: {} - table: - name: course_comment_star + name: course_comment_stars schema: public object_relationships: - name: course_comment @@ -2663,18 +2546,21 @@ - comment_uuid - user_uuid filter: {} + allow_aggregations: true - role: student permission: columns: - comment_uuid - user_uuid filter: {} + allow_aggregations: true - role: teacher permission: columns: - comment_uuid - user_uuid filter: {} + allow_aggregations: true update_permissions: - role: counselor permission: @@ -3961,41 +3847,6 @@ table: name: contest_team_member schema: public - - name: course_comment_comments - using: - foreign_key_constraint_on: - column: user_uuid - table: - name: course_comment_comment - schema: public - - name: course_comment_likes - using: - foreign_key_constraint_on: - column: user_uuid - table: - name: course_comment_like - schema: public - - name: course_comment_stars - using: - foreign_key_constraint_on: - column: user_uuid - table: - name: course_comment_star - schema: public - - name: course_comments - using: - foreign_key_constraint_on: - column: user_uuid - table: - name: course_comment - schema: public - - name: course_ratings - using: - foreign_key_constraint_on: - column: user_uuid - table: - name: course_rating - schema: public - name: mentor_application_as_mentor using: foreign_key_constraint_on: diff --git a/migrations/1716721070980_drop_table_public_course_comment_comment/down.sql b/migrations/1716721070980_drop_table_public_course_comment_comment/down.sql new file mode 100644 index 0000000..400e288 --- /dev/null +++ b/migrations/1716721070980_drop_table_public_course_comment_comment/down.sql @@ -0,0 +1,3 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- DROP table "public"."course_comment_comment"; diff --git a/migrations/1716721070980_drop_table_public_course_comment_comment/up.sql b/migrations/1716721070980_drop_table_public_course_comment_comment/up.sql new file mode 100644 index 0000000..bbe2895 --- /dev/null +++ b/migrations/1716721070980_drop_table_public_course_comment_comment/up.sql @@ -0,0 +1 @@ +DROP table "public"."course_comment_comment"; diff --git a/migrations/1716721863423_alter_table_public_course_comment_add_column_parent_uuid/down.sql b/migrations/1716721863423_alter_table_public_course_comment_add_column_parent_uuid/down.sql new file mode 100644 index 0000000..43bb6a3 --- /dev/null +++ b/migrations/1716721863423_alter_table_public_course_comment_add_column_parent_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"."course_comment" add column "parent_uuid" uuid +-- null; diff --git a/migrations/1716721863423_alter_table_public_course_comment_add_column_parent_uuid/up.sql b/migrations/1716721863423_alter_table_public_course_comment_add_column_parent_uuid/up.sql new file mode 100644 index 0000000..e6a9bfe --- /dev/null +++ b/migrations/1716721863423_alter_table_public_course_comment_add_column_parent_uuid/up.sql @@ -0,0 +1,2 @@ +alter table "public"."course_comment" add column "parent_uuid" uuid + null; diff --git a/migrations/1716721897201_set_fk_public_course_comment_parent_uuid/down.sql b/migrations/1716721897201_set_fk_public_course_comment_parent_uuid/down.sql new file mode 100644 index 0000000..27c8f9d --- /dev/null +++ b/migrations/1716721897201_set_fk_public_course_comment_parent_uuid/down.sql @@ -0,0 +1 @@ +alter table "public"."course_comment" drop constraint "course_comment_parent_uuid_fkey"; diff --git a/migrations/1716721897201_set_fk_public_course_comment_parent_uuid/up.sql b/migrations/1716721897201_set_fk_public_course_comment_parent_uuid/up.sql new file mode 100644 index 0000000..a9d28c4 --- /dev/null +++ b/migrations/1716721897201_set_fk_public_course_comment_parent_uuid/up.sql @@ -0,0 +1,5 @@ +alter table "public"."course_comment" + add constraint "course_comment_parent_uuid_fkey" + foreign key ("parent_uuid") + references "public"."course_comment" + ("uuid") on update restrict on delete restrict; diff --git a/migrations/1716723050648_rename_table_public_course_comment_star/down.sql b/migrations/1716723050648_rename_table_public_course_comment_star/down.sql new file mode 100644 index 0000000..9f2f582 --- /dev/null +++ b/migrations/1716723050648_rename_table_public_course_comment_star/down.sql @@ -0,0 +1 @@ +alter table "public"."course_comment_stars" rename to "course_comment_star"; diff --git a/migrations/1716723050648_rename_table_public_course_comment_star/up.sql b/migrations/1716723050648_rename_table_public_course_comment_star/up.sql new file mode 100644 index 0000000..15fcd2d --- /dev/null +++ b/migrations/1716723050648_rename_table_public_course_comment_star/up.sql @@ -0,0 +1 @@ +alter table "public"."course_comment_star" rename to "course_comment_stars"; diff --git a/migrations/1716723060912_rename_table_public_course_comment_like/down.sql b/migrations/1716723060912_rename_table_public_course_comment_like/down.sql new file mode 100644 index 0000000..1ad7d18 --- /dev/null +++ b/migrations/1716723060912_rename_table_public_course_comment_like/down.sql @@ -0,0 +1 @@ +alter table "public"."course_comment_likes" rename to "course_comment_like"; diff --git a/migrations/1716723060912_rename_table_public_course_comment_like/up.sql b/migrations/1716723060912_rename_table_public_course_comment_like/up.sql new file mode 100644 index 0000000..f184aee --- /dev/null +++ b/migrations/1716723060912_rename_table_public_course_comment_like/up.sql @@ -0,0 +1 @@ +alter table "public"."course_comment_like" rename to "course_comment_likes";