From 5039f9a506222b3f74312a4586166f5130e53817 Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Mon, 11 Mar 2024 00:24:56 +0900 Subject: Add table manage diary articles. --- deploy/articles.sql | 21 +++++++++++++++++++++ revert/articles.sql | 9 +++++++++ sqitch.plan | 1 + verify/articles.sql | 11 +++++++++++ 4 files changed, 42 insertions(+) create mode 100644 deploy/articles.sql create mode 100644 revert/articles.sql create mode 100644 verify/articles.sql diff --git a/deploy/articles.sql b/deploy/articles.sql new file mode 100644 index 0000000..8c259d1 --- /dev/null +++ b/deploy/articles.sql @@ -0,0 +1,21 @@ +-- Deploy diary:articles to pg +-- requires: schema + +BEGIN; + +SET search_path to diary; + +CREATE TABLE articles( + id UUID PRIMARY KEY, + timestamp TIMESTAMPTZ NOT NULL, + hash VARCHAR(64) NOT NULL, + title TEXT NOT NULL, + body TEXT NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +COMMENT ON COLUMN articles.hash is 'SHA256 of org subtrees'; +COMMENT ON COLUMN articles.body is 'HTML of org entries'; + +COMMIT; diff --git a/revert/articles.sql b/revert/articles.sql new file mode 100644 index 0000000..d1c4310 --- /dev/null +++ b/revert/articles.sql @@ -0,0 +1,9 @@ +-- Revert diary:articles from pg + +BEGIN; + +SET search_path to diary; + +DROP TABLE articles; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index af4c831..eea03de 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -4,3 +4,4 @@ schema 2024-03-10T11:00:19Z Masaya Tojo # Add schema for diary objects. update_updated_at [schema] 2024-03-10T11:29:05Z Masaya Tojo # Add function to update `updated_at` column. +articles [schema] 2024-03-10T13:54:19Z Masaya Tojo # Add table manage diary articles. diff --git a/verify/articles.sql b/verify/articles.sql new file mode 100644 index 0000000..9192a11 --- /dev/null +++ b/verify/articles.sql @@ -0,0 +1,11 @@ +-- Verify diary:articles on pg + +BEGIN; + +SET search_path to diary; + +SELECT id, timestamp, hash, title, body, created_at, updated_at + FROM articles + WHERE FALSE; + +ROLLBACK; -- cgit v1.2.3