diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-12 23:16:42 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-12 23:38:13 +0900 |
commit | a4a99033f2d3eb7e6d03387fe7e6618604885776 (patch) | |
tree | 1d15217fa34aa96327436d3bb237a2750601ecfb | |
parent | a9c3438a20e7eccfdd31414c2c71092ddda8f705 (diff) |
Add update_timestamp trigger to items table.
-rw-r--r-- | deploy/items_update_timestamp.sql | 12 | ||||
-rw-r--r-- | revert/items_update_timestamp.sql | 7 | ||||
-rw-r--r-- | sqitch.plan | 1 | ||||
-rw-r--r-- | verify/items_update_timestamp.sql | 14 |
4 files changed, 34 insertions, 0 deletions
diff --git a/deploy/items_update_timestamp.sql b/deploy/items_update_timestamp.sql new file mode 100644 index 0000000..f9258b2 --- /dev/null +++ b/deploy/items_update_timestamp.sql @@ -0,0 +1,12 @@ +-- Deploy kakeibo:items_update_timestamp to pg +-- requires: items +-- requires: update_timestamp + +BEGIN; + +CREATE OR REPLACE TRIGGER update_timestamp + BEFORE UPDATE ON kakeibo.items + FOR EACH ROW + EXECUTE FUNCTION kakeibo.update_timestamp(); + +COMMIT; diff --git a/revert/items_update_timestamp.sql b/revert/items_update_timestamp.sql new file mode 100644 index 0000000..52ce12f --- /dev/null +++ b/revert/items_update_timestamp.sql @@ -0,0 +1,7 @@ +-- Revert kakeibo:items_update_timestamp from pg + +BEGIN; + +DROP TRIGGER update_timestamp ON kakeibo.items; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index 7f881f9..95b4dcb 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -11,3 +11,4 @@ delete_item [schema items] 2023-03-12T08:14:34Z Masaya Tojo <masaya@tojo.tokyo> delete_transaction [schema transactions] 2023-03-12T08:40:47Z Masaya Tojo <masaya@tojo.tokyo> # Add function to delete transaction. update_timestamp [schema] 2023-03-12T13:57:49Z Masaya Tojo <masaya@tojo.tokyo> # Add function to update timestamp. transactions_update_timestamp [transactions update_timestamp] 2023-03-12T14:10:42Z Masaya Tojo <masaya@tojo.tokyo> # Add update_timestamp trigger to transactions table. +items_update_timestamp [items update_timestamp] 2023-03-12T14:14:13Z Masaya Tojo <masaya@tojo.tokyo> # Add update_timestamp trigger to items table. diff --git a/verify/items_update_timestamp.sql b/verify/items_update_timestamp.sql new file mode 100644 index 0000000..c7fe432 --- /dev/null +++ b/verify/items_update_timestamp.sql @@ -0,0 +1,14 @@ +-- Verify kakeibo:items_update_timestamp on pg + +BEGIN; + +DO $$ + BEGIN + ASSERT (SELECT 1 from information_schema.triggers + WHERE trigger_schema = 'kakeibo' + AND event_object_table = 'transactions' + AND trigger_name = 'update_timestamp'); + END +$$; + +ROLLBACK; |