From 47a910d64e1ed8339b9efc3bd929f55c85172cba Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Wed, 30 Aug 2023 00:49:46 +0900 Subject: Add table to manage diaries --- deploy/diaries.sql | 18 ++++++++++++++++++ revert/diaries.sql | 9 +++++++++ sqitch.plan | 1 + verify/diaries.sql | 11 +++++++++++ 4 files changed, 39 insertions(+) create mode 100644 deploy/diaries.sql create mode 100644 revert/diaries.sql create mode 100644 verify/diaries.sql diff --git a/deploy/diaries.sql b/deploy/diaries.sql new file mode 100644 index 0000000..3188490 --- /dev/null +++ b/deploy/diaries.sql @@ -0,0 +1,18 @@ +-- Deploy photos:diaries to pg +-- requires: schema +-- requires: photos + +BEGIN; + +SET search_path to photos; + +CREATE TABLE diaries ( + id UUID PRIMARY KEY, + photo_id UUID NOT NULL REFERENCES photos(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + title TEXT NOT NULL, + entry TEXT NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +COMMIT; diff --git a/revert/diaries.sql b/revert/diaries.sql new file mode 100644 index 0000000..6b5ea7c --- /dev/null +++ b/revert/diaries.sql @@ -0,0 +1,9 @@ +-- Revert photos:diaries from pg + +BEGIN; + +SET search_path to photos; + +DROP TABLE diaries; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index eb3f8f2..3e3ee77 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -6,3 +6,4 @@ schema 2023-08-27T13:52:33Z Masaya Tojo # Add schema for all photos [schema] 2023-08-29T13:12:25Z Masaya Tojo # Create table to manage my photos. update_timestamp [schema] 2023-08-29T15:03:35Z Masaya Tojo # Add function to update timestamp photos_update_timestamp [schema photos update_timestamp] 2023-08-29T15:15:40Z Masaya Tojo # Add update_timestamp trigger to photos table +diaries [schema photos] 2023-08-29T15:30:42Z Masaya Tojo # Add table to manage diaries diff --git a/verify/diaries.sql b/verify/diaries.sql new file mode 100644 index 0000000..654c2ff --- /dev/null +++ b/verify/diaries.sql @@ -0,0 +1,11 @@ +-- Verify photos:diaries on pg + +BEGIN; + +SET search_path to photos; + +SELECT id, photo_id, title, entry, created_at, updated_at + FROM diaries + WHERE FALSE; + +ROLLBACK; -- cgit v1.2.3