From 7822fd40d093508717ea4fb002b20be1e77ce82f Mon Sep 17 00:00:00 2001 From: FranGuam <53105842+FranGuam@users.noreply.github.com> Date: Fri, 17 May 2024 19:51:04 +0800 Subject: [PATCH] feat: tables for course (#176) * feat: tables for course * fix(ci) --- metadata/tables.yaml | 468 +++++++++++++++++- .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 17 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 21 + .../up.sql | 19 + 41 files changed, 546 insertions(+), 17 deletions(-) create mode 100644 migrations/1715862217496_alter_table_public_share_course_alter_column_year/down.sql create mode 100644 migrations/1715862217496_alter_table_public_share_course_alter_column_year/up.sql create mode 100644 migrations/1715862389376_rename_table_public_share_course/down.sql create mode 100644 migrations/1715862389376_rename_table_public_share_course/up.sql create mode 100644 migrations/1715862553637_create_table_public_course_manager/down.sql create mode 100644 migrations/1715862553637_create_table_public_course_manager/up.sql create mode 100644 migrations/1715863435652_create_table_public_course_info/down.sql create mode 100644 migrations/1715863435652_create_table_public_course_info/up.sql create mode 100644 migrations/1715863956306_create_table_public_course_comment/down.sql create mode 100644 migrations/1715863956306_create_table_public_course_comment/up.sql create mode 100644 migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/down.sql create mode 100644 migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/up.sql create mode 100644 migrations/1715865468541_create_table_public_course_rating/down.sql create mode 100644 migrations/1715865468541_create_table_public_course_rating/up.sql create mode 100644 migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/down.sql create mode 100644 migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/up.sql create mode 100644 migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/down.sql create mode 100644 migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/up.sql create mode 100644 migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/down.sql create mode 100644 migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/up.sql create mode 100644 migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/down.sql create mode 100644 migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/up.sql create mode 100644 migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/down.sql create mode 100644 migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/up.sql create mode 100644 migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/down.sql create mode 100644 migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/up.sql create mode 100644 migrations/1715865946838_alter_table_public_course_comment_alter_column_course/down.sql create mode 100644 migrations/1715865946838_alter_table_public_course_comment_alter_column_course/up.sql create mode 100644 migrations/1715865961801_alter_table_public_course_comment_alter_column_user/down.sql create mode 100644 migrations/1715865961801_alter_table_public_course_comment_alter_column_user/up.sql create mode 100644 migrations/1715865975726_alter_table_public_course_info_alter_column_course/down.sql create mode 100644 migrations/1715865975726_alter_table_public_course_info_alter_column_course/up.sql create mode 100644 migrations/1715865989663_alter_table_public_course_manager_alter_column_user/down.sql create mode 100644 migrations/1715865989663_alter_table_public_course_manager_alter_column_user/up.sql create mode 100644 migrations/1715866006997_alter_table_public_course_rating_alter_column_course/down.sql create mode 100644 migrations/1715866006997_alter_table_public_course_rating_alter_column_course/up.sql create mode 100644 migrations/1715866021810_alter_table_public_course_rating_alter_column_user/down.sql create mode 100644 migrations/1715866021810_alter_table_public_course_rating_alter_column_user/up.sql create mode 100644 migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/down.sql create mode 100644 migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/up.sql diff --git a/metadata/tables.yaml b/metadata/tables.yaml index 4754d1e..9b6b18f 100644 --- a/metadata/tables.yaml +++ b/metadata/tables.yaml @@ -2295,6 +2295,457 @@ contest_managers: user_uuid: _eq: X-Hasura-User-Id +- table: + name: course + schema: public + array_relationships: + - name: course_comments + using: + foreign_key_constraint_on: + column: course_id + table: + name: course_comment + schema: public + - name: course_infos + using: + foreign_key_constraint_on: + column: course_id + table: + name: course_info + schema: public + - name: course_ratings + using: + foreign_key_constraint_on: + column: course_id + table: + name: course_rating + schema: public + select_permissions: + - role: counselor + permission: + columns: + - year + - code + - fullname + - language + - name + - professor + - semester + - type + - uuid + filter: {} + - role: student + permission: + columns: + - year + - code + - fullname + - language + - name + - professor + - semester + - type + - uuid + filter: {} + - role: teacher + permission: + columns: + - year + - code + - fullname + - language + - name + - professor + - semester + - type + - uuid + filter: {} +- table: + name: course_comment + schema: public + object_relationships: + - name: course + using: + foreign_key_constraint_on: course_id + - name: user + using: + foreign_key_constraint_on: user_uuid + insert_permissions: + - role: counselor + permission: + check: {} + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + - role: student + permission: + check: {} + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + - role: teacher + permission: + check: {} + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + select_permissions: + - role: counselor + permission: + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + filter: {} + - role: student + permission: + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + filter: {} + - role: teacher + permission: + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + filter: {} + update_permissions: + - role: counselor + permission: + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + filter: {} + check: {} + - role: student + permission: + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - uuid + filter: {} + check: {} + - role: teacher + permission: + columns: + - comment + - created_at + - updated_at + - course_id + - user_uuid + - 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 + object_relationships: + - name: course + using: + foreign_key_constraint_on: course_id + insert_permissions: + - role: counselor + permission: + check: {} + columns: + - key + - value + - course_id + - role: student + permission: + check: {} + columns: + - key + - value + - course_id + - role: teacher + permission: + check: {} + columns: + - key + - value + - course_id + select_permissions: + - role: counselor + permission: + columns: + - course_id + - key + - value + filter: {} + - role: student + permission: + columns: + - course_id + - key + - value + filter: {} + - role: teacher + permission: + columns: + - course_id + - key + - value + filter: {} + update_permissions: + - role: counselor + permission: + columns: + - key + - value + - course_id + filter: {} + check: {} + - role: student + permission: + columns: + - key + - value + - course_id + filter: {} + check: {} + - role: teacher + permission: + columns: + - key + - value + - course_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: {} +- table: + name: course_manager + schema: public + object_relationships: + - name: user + using: + foreign_key_constraint_on: user_uuid + select_permissions: + - role: counselor + permission: + columns: + - user_uuid + filter: {} + - role: student + permission: + columns: + - user_uuid + filter: {} + - role: teacher + permission: + columns: + - user_uuid + filter: {} +- table: + name: course_rating + schema: public + object_relationships: + - name: course + using: + foreign_key_constraint_on: course_id + - name: user + using: + foreign_key_constraint_on: user_uuid + insert_permissions: + - role: counselor + permission: + check: {} + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + - role: student + permission: + check: {} + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + - role: teacher + permission: + check: {} + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + select_permissions: + - role: counselor + permission: + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + filter: {} + - role: student + permission: + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + filter: {} + - role: teacher + permission: + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + filter: {} + update_permissions: + - role: counselor + permission: + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + filter: {} + check: {} + - role: student + permission: + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - user_uuid + filter: {} + check: {} + - role: teacher + permission: + columns: + - dim1 + - dim2 + - dim3 + - dim4 + - dim5 + - dim6 + - created_at + - updated_at + - course_id + - 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: department schema: public @@ -3374,23 +3825,6 @@ - salutation - type filter: {} -- table: - name: share_course - schema: public - select_permissions: - - role: student - permission: - columns: - - year - - code - - fullname - - language - - name - - professor - - semester - - type - - uuid - filter: {} - table: name: users schema: public diff --git a/migrations/1715862217496_alter_table_public_share_course_alter_column_year/down.sql b/migrations/1715862217496_alter_table_public_share_course_alter_column_year/down.sql new file mode 100644 index 0000000..5635065 --- /dev/null +++ b/migrations/1715862217496_alter_table_public_share_course_alter_column_year/down.sql @@ -0,0 +1 @@ +alter table "public"."share_course" alter column "year" set default '2000'; diff --git a/migrations/1715862217496_alter_table_public_share_course_alter_column_year/up.sql b/migrations/1715862217496_alter_table_public_share_course_alter_column_year/up.sql new file mode 100644 index 0000000..a040a2f --- /dev/null +++ b/migrations/1715862217496_alter_table_public_share_course_alter_column_year/up.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."share_course" ALTER COLUMN "year" drop default; diff --git a/migrations/1715862389376_rename_table_public_share_course/down.sql b/migrations/1715862389376_rename_table_public_share_course/down.sql new file mode 100644 index 0000000..75926e9 --- /dev/null +++ b/migrations/1715862389376_rename_table_public_share_course/down.sql @@ -0,0 +1 @@ +alter table "public"."course" rename to "share_course"; diff --git a/migrations/1715862389376_rename_table_public_share_course/up.sql b/migrations/1715862389376_rename_table_public_share_course/up.sql new file mode 100644 index 0000000..2de3a72 --- /dev/null +++ b/migrations/1715862389376_rename_table_public_share_course/up.sql @@ -0,0 +1 @@ +alter table "public"."share_course" rename to "course"; diff --git a/migrations/1715862553637_create_table_public_course_manager/down.sql b/migrations/1715862553637_create_table_public_course_manager/down.sql new file mode 100644 index 0000000..c43a203 --- /dev/null +++ b/migrations/1715862553637_create_table_public_course_manager/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."course_manager"; diff --git a/migrations/1715862553637_create_table_public_course_manager/up.sql b/migrations/1715862553637_create_table_public_course_manager/up.sql new file mode 100644 index 0000000..ef44609 --- /dev/null +++ b/migrations/1715862553637_create_table_public_course_manager/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."course_manager" ("user" uuid NOT NULL, PRIMARY KEY ("user") , FOREIGN KEY ("user") REFERENCES "public"."users"("uuid") ON UPDATE restrict ON DELETE cascade, UNIQUE ("user"));COMMENT ON TABLE "public"."course_manager" IS E'课程共享平台的管理员'; diff --git a/migrations/1715863435652_create_table_public_course_info/down.sql b/migrations/1715863435652_create_table_public_course_info/down.sql new file mode 100644 index 0000000..fc3e9ae --- /dev/null +++ b/migrations/1715863435652_create_table_public_course_info/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."course_info"; diff --git a/migrations/1715863435652_create_table_public_course_info/up.sql b/migrations/1715863435652_create_table_public_course_info/up.sql new file mode 100644 index 0000000..3c79596 --- /dev/null +++ b/migrations/1715863435652_create_table_public_course_info/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."course_info" ("course_id" uuid NOT NULL, "key" text NOT NULL, "value" text, PRIMARY KEY ("course_id","key") , FOREIGN KEY ("course_id") REFERENCES "public"."course"("uuid") ON UPDATE restrict ON DELETE cascade);COMMENT ON TABLE "public"."course_info" IS E'课程信息键值对表,对manager开放编辑'; diff --git a/migrations/1715863956306_create_table_public_course_comment/down.sql b/migrations/1715863956306_create_table_public_course_comment/down.sql new file mode 100644 index 0000000..aab80f9 --- /dev/null +++ b/migrations/1715863956306_create_table_public_course_comment/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."course_comment"; diff --git a/migrations/1715863956306_create_table_public_course_comment/up.sql b/migrations/1715863956306_create_table_public_course_comment/up.sql new file mode 100644 index 0000000..983b5cf --- /dev/null +++ b/migrations/1715863956306_create_table_public_course_comment/up.sql @@ -0,0 +1,2 @@ +CREATE TABLE "public"."course_comment" ("uuid" uuid NOT NULL DEFAULT gen_random_uuid(), "course" uuid NOT NULL, "user" uuid NOT NULL, "comment" text NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("uuid") , FOREIGN KEY ("course") REFERENCES "public"."course"("uuid") ON UPDATE restrict ON DELETE cascade, FOREIGN KEY ("user") REFERENCES "public"."users"("uuid") ON UPDATE restrict ON DELETE cascade, UNIQUE ("uuid"));COMMENT ON TABLE "public"."course_comment" IS E'用户评论表'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/down.sql b/migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/down.sql new file mode 100644 index 0000000..b8451d9 --- /dev/null +++ b/migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/down.sql @@ -0,0 +1 @@ +alter table "public"."course_info" rename column "course" to "course_id"; diff --git a/migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/up.sql b/migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/up.sql new file mode 100644 index 0000000..e069b4e --- /dev/null +++ b/migrations/1715863998351_alter_table_public_course_info_alter_column_course_id/up.sql @@ -0,0 +1 @@ +alter table "public"."course_info" rename column "course_id" to "course"; diff --git a/migrations/1715865468541_create_table_public_course_rating/down.sql b/migrations/1715865468541_create_table_public_course_rating/down.sql new file mode 100644 index 0000000..bc5abc5 --- /dev/null +++ b/migrations/1715865468541_create_table_public_course_rating/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."course_rating"; diff --git a/migrations/1715865468541_create_table_public_course_rating/up.sql b/migrations/1715865468541_create_table_public_course_rating/up.sql new file mode 100644 index 0000000..a331ae3 --- /dev/null +++ b/migrations/1715865468541_create_table_public_course_rating/up.sql @@ -0,0 +1,17 @@ +CREATE TABLE "public"."course_rating" ("course" uuid NOT NULL, "user" uuid NOT NULL, "dim1" integer NOT NULL, "dim2" integer NOT NULL, "dim3" integer NOT NULL, "dim4" integer NOT NULL, "dim5" integer NOT NULL, "dim6" integer NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("course","user") , FOREIGN KEY ("course") REFERENCES "public"."course"("uuid") ON UPDATE restrict ON DELETE cascade, FOREIGN KEY ("user") REFERENCES "public"."users"("uuid") ON UPDATE restrict ON DELETE cascade);COMMENT ON TABLE "public"."course_rating" IS E'用户评分表'; +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_course_rating_updated_at" +BEFORE UPDATE ON "public"."course_rating" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_course_rating_updated_at" ON "public"."course_rating" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; diff --git a/migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/down.sql b/migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/down.sql new file mode 100644 index 0000000..1d7c0cb --- /dev/null +++ b/migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/down.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim1" is NULL; diff --git a/migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/up.sql b/migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/up.sql new file mode 100644 index 0000000..e71a41f --- /dev/null +++ b/migrations/1715865744257_alter_table_public_course_rating_alter_column_dim1/up.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim1" is E'任务量'; diff --git a/migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/down.sql b/migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/down.sql new file mode 100644 index 0000000..d9ed43f --- /dev/null +++ b/migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/down.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim2" is NULL; diff --git a/migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/up.sql b/migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/up.sql new file mode 100644 index 0000000..25c2ab0 --- /dev/null +++ b/migrations/1715865756507_alter_table_public_course_rating_alter_column_dim2/up.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim2" is E'内容难度'; diff --git a/migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/down.sql b/migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/down.sql new file mode 100644 index 0000000..7b5e5e7 --- /dev/null +++ b/migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/down.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim3" is NULL; diff --git a/migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/up.sql b/migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/up.sql new file mode 100644 index 0000000..b78cf33 --- /dev/null +++ b/migrations/1715865767848_alter_table_public_course_rating_alter_column_dim3/up.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim3" is E'上课质量'; diff --git a/migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/down.sql b/migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/down.sql new file mode 100644 index 0000000..6875bb5 --- /dev/null +++ b/migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/down.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim4" is NULL; diff --git a/migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/up.sql b/migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/up.sql new file mode 100644 index 0000000..c1a34e4 --- /dev/null +++ b/migrations/1715865788461_alter_table_public_course_rating_alter_column_dim4/up.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim4" is E'收获感'; diff --git a/migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/down.sql b/migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/down.sql new file mode 100644 index 0000000..030e7f6 --- /dev/null +++ b/migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/down.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim5" is NULL; diff --git a/migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/up.sql b/migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/up.sql new file mode 100644 index 0000000..5380dce --- /dev/null +++ b/migrations/1715865799918_alter_table_public_course_rating_alter_column_dim5/up.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim5" is E'给分好坏'; diff --git a/migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/down.sql b/migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/down.sql new file mode 100644 index 0000000..a8f5eca --- /dev/null +++ b/migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/down.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim6" is NULL; diff --git a/migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/up.sql b/migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/up.sql new file mode 100644 index 0000000..5185556 --- /dev/null +++ b/migrations/1715865812399_alter_table_public_course_rating_alter_column_dim6/up.sql @@ -0,0 +1 @@ +comment on column "public"."course_rating"."dim6" is E'考试作业讲课相关度'; diff --git a/migrations/1715865946838_alter_table_public_course_comment_alter_column_course/down.sql b/migrations/1715865946838_alter_table_public_course_comment_alter_column_course/down.sql new file mode 100644 index 0000000..6382d11 --- /dev/null +++ b/migrations/1715865946838_alter_table_public_course_comment_alter_column_course/down.sql @@ -0,0 +1 @@ +alter table "public"."course_comment" rename column "course_id" to "course"; diff --git a/migrations/1715865946838_alter_table_public_course_comment_alter_column_course/up.sql b/migrations/1715865946838_alter_table_public_course_comment_alter_column_course/up.sql new file mode 100644 index 0000000..ab3f4db --- /dev/null +++ b/migrations/1715865946838_alter_table_public_course_comment_alter_column_course/up.sql @@ -0,0 +1 @@ +alter table "public"."course_comment" rename column "course" to "course_id"; diff --git a/migrations/1715865961801_alter_table_public_course_comment_alter_column_user/down.sql b/migrations/1715865961801_alter_table_public_course_comment_alter_column_user/down.sql new file mode 100644 index 0000000..1a434c5 --- /dev/null +++ b/migrations/1715865961801_alter_table_public_course_comment_alter_column_user/down.sql @@ -0,0 +1 @@ +alter table "public"."course_comment" rename column "user_uuid" to "user"; diff --git a/migrations/1715865961801_alter_table_public_course_comment_alter_column_user/up.sql b/migrations/1715865961801_alter_table_public_course_comment_alter_column_user/up.sql new file mode 100644 index 0000000..2a9687a --- /dev/null +++ b/migrations/1715865961801_alter_table_public_course_comment_alter_column_user/up.sql @@ -0,0 +1 @@ +alter table "public"."course_comment" rename column "user" to "user_uuid"; diff --git a/migrations/1715865975726_alter_table_public_course_info_alter_column_course/down.sql b/migrations/1715865975726_alter_table_public_course_info_alter_column_course/down.sql new file mode 100644 index 0000000..e069b4e --- /dev/null +++ b/migrations/1715865975726_alter_table_public_course_info_alter_column_course/down.sql @@ -0,0 +1 @@ +alter table "public"."course_info" rename column "course_id" to "course"; diff --git a/migrations/1715865975726_alter_table_public_course_info_alter_column_course/up.sql b/migrations/1715865975726_alter_table_public_course_info_alter_column_course/up.sql new file mode 100644 index 0000000..b8451d9 --- /dev/null +++ b/migrations/1715865975726_alter_table_public_course_info_alter_column_course/up.sql @@ -0,0 +1 @@ +alter table "public"."course_info" rename column "course" to "course_id"; diff --git a/migrations/1715865989663_alter_table_public_course_manager_alter_column_user/down.sql b/migrations/1715865989663_alter_table_public_course_manager_alter_column_user/down.sql new file mode 100644 index 0000000..7d869d1 --- /dev/null +++ b/migrations/1715865989663_alter_table_public_course_manager_alter_column_user/down.sql @@ -0,0 +1 @@ +alter table "public"."course_manager" rename column "user_uuid" to "user"; diff --git a/migrations/1715865989663_alter_table_public_course_manager_alter_column_user/up.sql b/migrations/1715865989663_alter_table_public_course_manager_alter_column_user/up.sql new file mode 100644 index 0000000..4520f0b --- /dev/null +++ b/migrations/1715865989663_alter_table_public_course_manager_alter_column_user/up.sql @@ -0,0 +1 @@ +alter table "public"."course_manager" rename column "user" to "user_uuid"; diff --git a/migrations/1715866006997_alter_table_public_course_rating_alter_column_course/down.sql b/migrations/1715866006997_alter_table_public_course_rating_alter_column_course/down.sql new file mode 100644 index 0000000..3037a44 --- /dev/null +++ b/migrations/1715866006997_alter_table_public_course_rating_alter_column_course/down.sql @@ -0,0 +1 @@ +alter table "public"."course_rating" rename column "course_id" to "course"; diff --git a/migrations/1715866006997_alter_table_public_course_rating_alter_column_course/up.sql b/migrations/1715866006997_alter_table_public_course_rating_alter_column_course/up.sql new file mode 100644 index 0000000..fe6a94d --- /dev/null +++ b/migrations/1715866006997_alter_table_public_course_rating_alter_column_course/up.sql @@ -0,0 +1 @@ +alter table "public"."course_rating" rename column "course" to "course_id"; diff --git a/migrations/1715866021810_alter_table_public_course_rating_alter_column_user/down.sql b/migrations/1715866021810_alter_table_public_course_rating_alter_column_user/down.sql new file mode 100644 index 0000000..fa89f51 --- /dev/null +++ b/migrations/1715866021810_alter_table_public_course_rating_alter_column_user/down.sql @@ -0,0 +1 @@ +alter table "public"."course_rating" rename column "user_uuid" to "user"; diff --git a/migrations/1715866021810_alter_table_public_course_rating_alter_column_user/up.sql b/migrations/1715866021810_alter_table_public_course_rating_alter_column_user/up.sql new file mode 100644 index 0000000..aff0553 --- /dev/null +++ b/migrations/1715866021810_alter_table_public_course_rating_alter_column_user/up.sql @@ -0,0 +1 @@ +alter table "public"."course_rating" rename column "user" to "user_uuid"; diff --git a/migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/down.sql b/migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/down.sql new file mode 100644 index 0000000..5183080 --- /dev/null +++ b/migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/down.sql @@ -0,0 +1,21 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."course_comment" add column "updated_at" timestamptz +-- null default now(); +-- +-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +-- RETURNS TRIGGER AS $$ +-- DECLARE +-- _new record; +-- BEGIN +-- _new := NEW; +-- _new."updated_at" = NOW(); +-- RETURN _new; +-- END; +-- $$ LANGUAGE plpgsql; +-- CREATE TRIGGER "set_public_course_comment_updated_at" +-- BEFORE UPDATE ON "public"."course_comment" +-- FOR EACH ROW +-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +-- COMMENT ON TRIGGER "set_public_course_comment_updated_at" ON "public"."course_comment" +-- IS 'trigger to set value of column "updated_at" to current timestamp on row update'; diff --git a/migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/up.sql b/migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/up.sql new file mode 100644 index 0000000..93f969d --- /dev/null +++ b/migrations/1715945631359_alter_table_public_course_comment_add_column_updated_at/up.sql @@ -0,0 +1,19 @@ +alter table "public"."course_comment" add column "updated_at" timestamptz + null default now(); + +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_course_comment_updated_at" +BEFORE UPDATE ON "public"."course_comment" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_course_comment_updated_at" ON "public"."course_comment" +IS 'trigger to set value of column "updated_at" to current timestamp on row update';