From b121761eb44b8fd8a8aee4e0945f6a7dcec9c719 Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Sun, 5 Mar 2023 23:35:09 +0900 Subject: Add article_id column to items table. --- deploy/items_article_id.sql | 11 +++++++++++ revert/items_article_id.sql | 8 ++++++++ sqitch.plan | 1 + verify/items_article_id.sql | 9 +++++++++ 4 files changed, 29 insertions(+) create mode 100644 deploy/items_article_id.sql create mode 100644 revert/items_article_id.sql create mode 100644 verify/items_article_id.sql diff --git a/deploy/items_article_id.sql b/deploy/items_article_id.sql new file mode 100644 index 0000000..4bb33ad --- /dev/null +++ b/deploy/items_article_id.sql @@ -0,0 +1,11 @@ +-- Deploy kakeibo:items_article_id to pg +-- requires: items +-- requires: articles + +BEGIN; + +ALTER TABLE kakeibo.items + ADD COLUMN article_id INTEGER, + ADD CONSTRAINT items_article_id_fkey FOREIGN KEY (article_id) REFERENCES kakeibo.articles (id); + +COMMIT; diff --git a/revert/items_article_id.sql b/revert/items_article_id.sql new file mode 100644 index 0000000..9b00f48 --- /dev/null +++ b/revert/items_article_id.sql @@ -0,0 +1,8 @@ +-- Revert kakeibo:items_article_id from pg + +BEGIN; + +ALTER TABLE kakeibo.items + DROP COLUMN article_id; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index cdf5342..0cea7ae 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -29,3 +29,4 @@ insert_transaction [insert_transaction@v1.0.0-dev3 appschema transactions] 2023- articles [appschema] 2023-03-05T14:01:38Z Masaya Tojo # Add table for link to diary articles. transactions_article_id [transactions articles] 2023-03-05T14:25:46Z Masaya Tojo # Add article_id column to transactions table. +items_article_id [items articles] 2023-03-05T14:32:43Z Masaya Tojo # Add article_id column to items table. diff --git a/verify/items_article_id.sql b/verify/items_article_id.sql new file mode 100644 index 0000000..4ab5e87 --- /dev/null +++ b/verify/items_article_id.sql @@ -0,0 +1,9 @@ +-- Verify kakeibo:items_article_id on pg + +BEGIN; + +SELECT article_id + FROM kakeibo.items + WHERE FALSE; + +ROLLBACK; -- cgit v1.2.3