diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-01 02:07:26 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-02 09:22:37 +0900 |
commit | 3750a87a1b21ebb169d0bdb70833a85d7f20c6b1 (patch) | |
tree | 48dde09d6f4bd50710f858ae4b6ba6c7772f6ebd | |
parent | d97bccef31c3a16be43bf94ed1632d22e61298b4 (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..31bb84c --- /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 5da13ea..c3c5b8c 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -12,3 +12,4 @@ insert_item [appschema items] 2023-02-28T13:13:22Z Masaya Tojo <masaya@tojo.toky delete_item [appschema items] 2023-02-28T13:13:39Z Masaya Tojo <masaya@tojo.tokyo> # Add function to delete item. update_timestamp [appschema] 2023-02-28T14:30:04Z Masaya Tojo <masaya@tojo.tokyo> # Add triger function to update a timestamp. transactions_update_timestamp [transactions update_timestamp] 2023-02-28T16:43:49Z Masaya Tojo <masaya@tojo.tokyo> # Add update_timestamp trigger to transactions table. +items_update_timestamp [items update_timestamp] 2023-02-28T17:04:02Z 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..a2daf86 --- /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 = 'items' + AND trigger_name = 'update_timestamp'); + END +$$; + +ROLLBACK; |