diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2024-03-11 01:09:12 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2024-03-11 01:09:12 +0900 |
commit | 1fd13d3895ba1274c1754379b3003b1e4f9840ab (patch) | |
tree | f62cac581bd047dd1e951da1b6a1f8adf08c9c39 | |
parent | 8fdc5179b1d5ba075c74f28337f1c83e28240ed2 (diff) |
Add update_updated_at trigger to article_tags table.
-rw-r--r-- | deploy/article_tags_update_updated_at.sql | 15 | ||||
-rw-r--r-- | revert/article_tags_update_updated_at.sql | 9 | ||||
-rw-r--r-- | sqitch.plan | 1 | ||||
-rw-r--r-- | verify/article_tags_update_updated_at.sql | 14 |
4 files changed, 39 insertions, 0 deletions
diff --git a/deploy/article_tags_update_updated_at.sql b/deploy/article_tags_update_updated_at.sql new file mode 100644 index 0000000..20d3bc7 --- /dev/null +++ b/deploy/article_tags_update_updated_at.sql @@ -0,0 +1,15 @@ +-- Deploy diary:article_tags_update_updated_at to pg +-- requires: schema +-- requires: article_tags +-- requires: update_updated_at + +BEGIN; + +SET search_path to diary; + +CREATE OR REPLACE TRIGGER update_updated_at + BEFORE UPDATE ON article_tags + FOR EACH ROW + EXECUTE FUNCTION update_updated_at(); + +COMMIT; diff --git a/revert/article_tags_update_updated_at.sql b/revert/article_tags_update_updated_at.sql new file mode 100644 index 0000000..7a668ab --- /dev/null +++ b/revert/article_tags_update_updated_at.sql @@ -0,0 +1,9 @@ +-- Revert diary:article_tags_update_updated_at from pg + +BEGIN; + +SET search_path to diary; + +DROP TRIGGER update_updated_at ON article_tags; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index c4be025..ec848cf 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -7,3 +7,4 @@ update_updated_at [schema] 2024-03-10T11:29:05Z Masaya Tojo <masaya@tojo.tokyo> 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. article_tags [schema] 2024-03-10T15:55:56Z Masaya Tojo <masaya@tojo.tokyo> # Add table manage diary article tags. +article_tags_update_updated_at [schema article_tags update_updated_at] 2024-03-10T16:06:54Z Masaya Tojo <masaya@tojo.tokyo> # Add update_updated_at trigger to article_tags table. diff --git a/verify/article_tags_update_updated_at.sql b/verify/article_tags_update_updated_at.sql new file mode 100644 index 0000000..7ee95db --- /dev/null +++ b/verify/article_tags_update_updated_at.sql @@ -0,0 +1,14 @@ +-- Verify diary:article_tags_update_updated_at on pg + +BEGIN; + +DO $$ + BEGIN + ASSERT (SELECT 1 from information_schema.triggers + WHERE trigger_schema = 'diary' + AND event_object_table = 'article_tags' + AND trigger_name = 'update_updated_at'); + END +$$; + +ROLLBACK; |