aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--deploy/articles_update_timestamp.sql12
-rw-r--r--revert/articles_update_timestamp.sql7
-rw-r--r--sqitch.plan1
-rw-r--r--verify/articles_update_timestamp.sql14
4 files changed, 34 insertions, 0 deletions
diff --git a/deploy/articles_update_timestamp.sql b/deploy/articles_update_timestamp.sql
new file mode 100644
index 0000000..56e4503
--- /dev/null
+++ b/deploy/articles_update_timestamp.sql
@@ -0,0 +1,12 @@
+-- Deploy kakeibo:articles_update_timestamp to pg
+-- requires: articles
+-- requires: update_timestamp
+
+BEGIN;
+
+CREATE OR REPLACE TRIGGER update_timestamp
+ BEFORE UPDATE ON kakeibo.articles
+ FOR EACH ROW
+ EXECUTE FUNCTION kakeibo.update_timestamp();
+
+COMMIT;
diff --git a/revert/articles_update_timestamp.sql b/revert/articles_update_timestamp.sql
new file mode 100644
index 0000000..3ce73d1
--- /dev/null
+++ b/revert/articles_update_timestamp.sql
@@ -0,0 +1,7 @@
+-- Revert kakeibo:articles_update_timestamp from pg
+
+BEGIN;
+
+DROP TRIGGER update_timestamp ON kakeibo.articles;
+
+COMMIT;
diff --git a/sqitch.plan b/sqitch.plan
index 870ff72..b4100bc 100644
--- a/sqitch.plan
+++ b/sqitch.plan
@@ -20,3 +20,4 @@ items [items@v1.0.0-alpha.1 articles] 2023-03-12T15:12:15Z Masaya Tojo <masaya@t
@v1.0.0-alpha.2 2023-03-12T15:18:49Z Masaya Tojo <masaya@tojo.tokyo> # Tag v1.0.0-alpha.2.
transaction_types [schema] 2023-03-12T15:20:07Z Masaya Tojo <masaya@tojo.tokyo> # Add table to manage transaction type codes.
+articles_update_timestamp [articles update_timestamp] 2023-03-12T15:38:43Z Masaya Tojo <masaya@tojo.tokyo> # Add update_timestamp trigger to articles table.
diff --git a/verify/articles_update_timestamp.sql b/verify/articles_update_timestamp.sql
new file mode 100644
index 0000000..f1952b3
--- /dev/null
+++ b/verify/articles_update_timestamp.sql
@@ -0,0 +1,14 @@
+-- Verify kakeibo:articles_update_timestamp on pg
+
+BEGIN;
+
+DO $$
+ BEGIN
+ ASSERT (SELECT 1 from information_schema.triggers
+ WHERE trigger_schema = 'kakeibo'
+ AND event_object_table = 'articles'
+ AND trigger_name = 'update_timestamp');
+ END
+$$;
+
+ROLLBACK;