aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2023-03-05 23:35:09 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2023-03-05 23:35:09 +0900
commitb121761eb44b8fd8a8aee4e0945f6a7dcec9c719 (patch)
treede324810f40a472260e3dd170dc18c19fdd91091
parent3f999d647e972e4f7fd807832bc4544f7aaecede (diff)
Add article_id column to items table.
-rw-r--r--deploy/items_article_id.sql11
-rw-r--r--revert/items_article_id.sql8
-rw-r--r--sqitch.plan1
-rw-r--r--verify/items_article_id.sql9
4 files changed, 29 insertions, 0 deletions
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 <masaya@tojo.tokyo> # Add table for link to diary articles.
transactions_article_id [transactions articles] 2023-03-05T14:25:46Z Masaya Tojo <masaya@tojo.tokyo> # Add article_id column to transactions table.
+items_article_id [items articles] 2023-03-05T14:32:43Z Masaya Tojo <masaya@tojo.tokyo> # 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;