From b74587df220972aaf7837d5696ad2e071fdea50d Mon Sep 17 00:00:00 2001 From: FranGuam Date: Fri, 17 May 2024 19:34:26 +0800 Subject: [PATCH] fix(ci) --- .../down.sql | 21 +++++++++++++++++++ .../up.sql | 19 +++++++++++++++++ 2 files changed, 40 insertions(+) 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/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';