diff options
-rw-r--r-- | deploy/articles_update_updated_at.sql | 15 | ||||
-rw-r--r-- | revert/articles_update_updated_at.sql | 9 | ||||
-rw-r--r-- | sqitch.plan | 1 | ||||
-rw-r--r-- | verify/articles_update_updated_at.sql | 14 |
4 files changed, 39 insertions, 0 deletions
diff --git a/deploy/articles_update_updated_at.sql b/deploy/articles_update_updated_at.sql new file mode 100644 index 0000000..31b7ccd --- /dev/null +++ b/deploy/articles_update_updated_at.sql @@ -0,0 +1,15 @@ +-- Deploy diary:articles_update_updated_at to pg +-- requires: schema +-- requires: articles +-- requires: update_updated_at + +BEGIN; + +SET search_path to diary; + +CREATE OR REPLACE TRIGGER update_updated_at + BEFORE UPDATE ON articles + FOR EACH ROW + EXECUTE FUNCTION update_updated_at(); + +COMMIT; diff --git a/revert/articles_update_updated_at.sql b/revert/articles_update_updated_at.sql new file mode 100644 index 0000000..bed20cf --- /dev/null +++ b/revert/articles_update_updated_at.sql @@ -0,0 +1,9 @@ +-- Revert diary:articles_update_updated_at from pg + +BEGIN; + +SET search_path to diary; + +DROP TRIGGER update_updated_at ON articles; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index eea03de..47af4b2 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -5,3 +5,4 @@ schema 2024-03-10T11:00:19Z Masaya Tojo <masaya@tojo.tokyo> # Add schema for diary objects. update_updated_at [schema] 2024-03-10T11:29:05Z Masaya Tojo <masaya@tojo.tokyo> # Add function to update `updated_at` column. articles [schema] 2024-03-10T13:54:19Z Masaya Tojo <masaya@tojo.tokyo> # Add table manage diary articles. +articles_update_updated_at [schema articles update_updated_at] 2024-03-10T15:28:20Z Masaya Tojo <masaya@tojo.tokyo> # Add update_updated_at trigger to articles table. diff --git a/verify/articles_update_updated_at.sql b/verify/articles_update_updated_at.sql new file mode 100644 index 0000000..744b1fd --- /dev/null +++ b/verify/articles_update_updated_at.sql @@ -0,0 +1,14 @@ +-- Verify diary:articles_update_updated_at on pg + +BEGIN; + +DO $$ + BEGIN + ASSERT (SELECT 1 from information_schema.triggers + WHERE trigger_schema = 'diary' + AND event_object_table = 'articles' + AND trigger_name = 'update_updated_at'); + END +$$; + +ROLLBACK; |