diff --git a/metadata/tables.yaml b/metadata/tables.yaml index 8b54209..2209965 100644 --- a/metadata/tables.yaml +++ b/metadata/tables.yaml @@ -2370,15 +2370,37 @@ - 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 - user_uuid - uuid - role: student @@ -2386,9 +2408,9 @@ check: {} columns: - comment + - course_id - created_at - updated_at - - course_id - user_uuid - uuid - role: teacher @@ -2396,9 +2418,9 @@ check: {} columns: - comment + - course_id - created_at - updated_at - - course_id - user_uuid - uuid select_permissions: @@ -2408,8 +2430,6 @@ - comment - course_id - created_at - - like - - star - updated_at - user_uuid - uuid @@ -2420,8 +2440,6 @@ - comment - course_id - created_at - - like - - star - updated_at - user_uuid - uuid @@ -2430,9 +2448,9 @@ permission: columns: - comment + - course_id - created_at - updated_at - - course_id - user_uuid - uuid filter: {} @@ -2441,9 +2459,9 @@ permission: columns: - comment + - course_id - created_at - updated_at - - course_id - user_uuid - uuid filter: {} @@ -2452,9 +2470,9 @@ permission: columns: - comment + - course_id - created_at - updated_at - - course_id - user_uuid - uuid filter: {} @@ -2463,9 +2481,9 @@ permission: columns: - comment + - course_id - created_at - updated_at - - course_id - user_uuid - uuid filter: {} @@ -2483,6 +2501,282 @@ permission: 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 + 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_uuid + - user_uuid + - role: student + permission: + check: {} + columns: + - comment_uuid + - user_uuid + - role: teacher + permission: + check: {} + columns: + - comment_uuid + - user_uuid + select_permissions: + - role: counselor + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + - role: student + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + - role: teacher + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + update_permissions: + - role: counselor + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + check: {} + - role: student + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + check: {} + - role: teacher + permission: + columns: + - 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_star + 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_uuid + - user_uuid + - role: student + permission: + check: {} + columns: + - comment_uuid + - user_uuid + - role: teacher + permission: + check: {} + columns: + - comment_uuid + - user_uuid + select_permissions: + - role: counselor + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + - role: student + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + - role: teacher + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + update_permissions: + - role: counselor + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + check: {} + - role: student + permission: + columns: + - comment_uuid + - user_uuid + filter: {} + check: {} + - role: teacher + permission: + columns: + - 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_info schema: public @@ -3848,6 +4142,41 @@ 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/1716647830860_create_schema_course_comment_likes/down.sql b/migrations/1716647830860_create_schema_course_comment_likes/down.sql new file mode 100644 index 0000000..66dab02 --- /dev/null +++ b/migrations/1716647830860_create_schema_course_comment_likes/down.sql @@ -0,0 +1 @@ +drop schema "course_comment_likes" cascade; diff --git a/migrations/1716647830860_create_schema_course_comment_likes/up.sql b/migrations/1716647830860_create_schema_course_comment_likes/up.sql new file mode 100644 index 0000000..081a9fe --- /dev/null +++ b/migrations/1716647830860_create_schema_course_comment_likes/up.sql @@ -0,0 +1 @@ +create schema "course_comment_likes"; diff --git a/migrations/1716647853247_drop_schema_course_comment_likes/down.sql b/migrations/1716647853247_drop_schema_course_comment_likes/down.sql new file mode 100644 index 0000000..0a45aa5 --- /dev/null +++ b/migrations/1716647853247_drop_schema_course_comment_likes/down.sql @@ -0,0 +1,3 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- drop schema "course_comment_likes" cascade; diff --git a/migrations/1716647853247_drop_schema_course_comment_likes/up.sql b/migrations/1716647853247_drop_schema_course_comment_likes/up.sql new file mode 100644 index 0000000..66dab02 --- /dev/null +++ b/migrations/1716647853247_drop_schema_course_comment_likes/up.sql @@ -0,0 +1 @@ +drop schema "course_comment_likes" cascade; diff --git a/migrations/1716648034386_create_table_public_course_comment_likes/down.sql b/migrations/1716648034386_create_table_public_course_comment_likes/down.sql new file mode 100644 index 0000000..45354b3 --- /dev/null +++ b/migrations/1716648034386_create_table_public_course_comment_likes/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."course_comment_likes"; diff --git a/migrations/1716648034386_create_table_public_course_comment_likes/up.sql b/migrations/1716648034386_create_table_public_course_comment_likes/up.sql new file mode 100644 index 0000000..9300770 --- /dev/null +++ b/migrations/1716648034386_create_table_public_course_comment_likes/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."course_comment_likes" ("comment_uuid" uuid NOT NULL, "user_uuid" uuid NOT NULL, PRIMARY KEY ("comment_uuid","user_uuid") , FOREIGN KEY ("comment_uuid") REFERENCES "public"."course_comment"("uuid") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("user_uuid") REFERENCES "public"."users"("uuid") ON UPDATE restrict ON DELETE restrict); diff --git a/migrations/1716648079409_rename_table_public_course_comment_likes/down.sql b/migrations/1716648079409_rename_table_public_course_comment_likes/down.sql new file mode 100644 index 0000000..f184aee --- /dev/null +++ b/migrations/1716648079409_rename_table_public_course_comment_likes/down.sql @@ -0,0 +1 @@ +alter table "public"."course_comment_like" rename to "course_comment_likes"; diff --git a/migrations/1716648079409_rename_table_public_course_comment_likes/up.sql b/migrations/1716648079409_rename_table_public_course_comment_likes/up.sql new file mode 100644 index 0000000..1ad7d18 --- /dev/null +++ b/migrations/1716648079409_rename_table_public_course_comment_likes/up.sql @@ -0,0 +1 @@ +alter table "public"."course_comment_likes" rename to "course_comment_like"; diff --git a/migrations/1716648207596_create_table_public_course_comment_star/down.sql b/migrations/1716648207596_create_table_public_course_comment_star/down.sql new file mode 100644 index 0000000..1e326ac --- /dev/null +++ b/migrations/1716648207596_create_table_public_course_comment_star/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."course_comment_star"; diff --git a/migrations/1716648207596_create_table_public_course_comment_star/up.sql b/migrations/1716648207596_create_table_public_course_comment_star/up.sql new file mode 100644 index 0000000..f4cf9b1 --- /dev/null +++ b/migrations/1716648207596_create_table_public_course_comment_star/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."course_comment_star" ("comment_uuid" uuid NOT NULL, "user_uuid" uuid NOT NULL, PRIMARY KEY ("comment_uuid","user_uuid") , FOREIGN KEY ("comment_uuid") REFERENCES "public"."course_comment"("uuid") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("user_uuid") REFERENCES "public"."users"("uuid") ON UPDATE restrict ON DELETE restrict); diff --git a/migrations/1716648788527_alter_table_public_course_comment_drop_column_star/down.sql b/migrations/1716648788527_alter_table_public_course_comment_drop_column_star/down.sql new file mode 100644 index 0000000..7da26c1 --- /dev/null +++ b/migrations/1716648788527_alter_table_public_course_comment_drop_column_star/down.sql @@ -0,0 +1,4 @@ +comment on column "public"."course_comment"."star" is E'用户评论表'; +alter table "public"."course_comment" alter column "star" set default 0; +alter table "public"."course_comment" alter column "star" drop not null; +alter table "public"."course_comment" add column "star" int4; diff --git a/migrations/1716648788527_alter_table_public_course_comment_drop_column_star/up.sql b/migrations/1716648788527_alter_table_public_course_comment_drop_column_star/up.sql new file mode 100644 index 0000000..3ccbef0 --- /dev/null +++ b/migrations/1716648788527_alter_table_public_course_comment_drop_column_star/up.sql @@ -0,0 +1 @@ +alter table "public"."course_comment" drop column "star" cascade; diff --git a/migrations/1716648798356_alter_table_public_course_comment_drop_column_like/down.sql b/migrations/1716648798356_alter_table_public_course_comment_drop_column_like/down.sql new file mode 100644 index 0000000..8aa474b --- /dev/null +++ b/migrations/1716648798356_alter_table_public_course_comment_drop_column_like/down.sql @@ -0,0 +1,4 @@ +comment on column "public"."course_comment"."like" is E'用户评论表'; +alter table "public"."course_comment" alter column "like" set default 0; +alter table "public"."course_comment" alter column "like" drop not null; +alter table "public"."course_comment" add column "like" int4; diff --git a/migrations/1716648798356_alter_table_public_course_comment_drop_column_like/up.sql b/migrations/1716648798356_alter_table_public_course_comment_drop_column_like/up.sql new file mode 100644 index 0000000..f29a536 --- /dev/null +++ b/migrations/1716648798356_alter_table_public_course_comment_drop_column_like/up.sql @@ -0,0 +1 @@ +alter table "public"."course_comment" drop column "like" cascade; diff --git a/migrations/1716648953179_create_table_public_course_comment_comment/down.sql b/migrations/1716648953179_create_table_public_course_comment_comment/down.sql new file mode 100644 index 0000000..0e2af18 --- /dev/null +++ b/migrations/1716648953179_create_table_public_course_comment_comment/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."course_comment_comment"; diff --git a/migrations/1716648953179_create_table_public_course_comment_comment/up.sql b/migrations/1716648953179_create_table_public_course_comment_comment/up.sql new file mode 100644 index 0000000..f212cc0 --- /dev/null +++ b/migrations/1716648953179_create_table_public_course_comment_comment/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."course_comment_comment" ("comment_uuid" uuid NOT NULL, "user_uuid" uuid NOT NULL, "comment" text NOT NULL, "create_at" timestamptz NOT NULL DEFAULT now(), "update_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("comment_uuid","user_uuid") , FOREIGN KEY ("comment_uuid") REFERENCES "public"."course_comment"("uuid") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("user_uuid") REFERENCES "public"."users"("uuid") ON UPDATE restrict ON DELETE restrict);