diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-13 00:11:31 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-13 00:17:07 +0900 |
commit | 05b6e730fa81a4ec02fbf361967896f0c9f3a2d4 (patch) | |
tree | e14b724d2a81bd394cb3cf38b86e1671e491bb68 | |
parent | aae863e98b35152e8e7c0efe7919dd105c229361 (diff) |
Add article_id column to transactions table.
-rw-r--r-- | deploy/transactions.sql | 13 | ||||
-rw-r--r-- | deploy/transactions@v1.0.0-alpha.1.sql | 15 | ||||
-rw-r--r-- | revert/transactions.sql | 3 | ||||
-rw-r--r-- | revert/transactions@v1.0.0-alpha.1.sql | 7 | ||||
-rw-r--r-- | sqitch.plan | 1 | ||||
-rw-r--r-- | verify/transactions.sql | 3 | ||||
-rw-r--r-- | verify/transactions@v1.0.0-alpha.1.sql | 14 |
7 files changed, 46 insertions, 10 deletions
diff --git a/deploy/transactions.sql b/deploy/transactions.sql index e37b276..0572a23 100644 --- a/deploy/transactions.sql +++ b/deploy/transactions.sql @@ -1,15 +1,12 @@ -- Deploy kakeibo:transactions to pg -- requires: schema +-- requires: articles BEGIN; -CREATE TABLE kakeibo.transactions ( - id SERIAL PRIMARY KEY, - type_code INTEGER, - date DATE NOT NULL, - note TEXT, - created_at TIMESTAMP NOT NULL DEFAULT NOW(), - updated_at TIMESTAMP NOT NULL DEFAULT NOW() -); +ALTER TABLE kakeibo.transactions + ADD COLUMN article_id INTEGER, + ADD CONSTRAINT transactions_article_id_fkey + FOREIGN KEY (article_id) REFERENCES kakeibo.articles (id); COMMIT; diff --git a/deploy/transactions@v1.0.0-alpha.1.sql b/deploy/transactions@v1.0.0-alpha.1.sql new file mode 100644 index 0000000..e37b276 --- /dev/null +++ b/deploy/transactions@v1.0.0-alpha.1.sql @@ -0,0 +1,15 @@ +-- Deploy kakeibo:transactions to pg +-- requires: schema + +BEGIN; + +CREATE TABLE kakeibo.transactions ( + id SERIAL PRIMARY KEY, + type_code INTEGER, + date DATE NOT NULL, + note TEXT, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +COMMIT; diff --git a/revert/transactions.sql b/revert/transactions.sql index 835ff3d..d30390a 100644 --- a/revert/transactions.sql +++ b/revert/transactions.sql @@ -2,6 +2,7 @@ BEGIN; -DROP TABLE kakeibo.transactions; +ALTER TABLE kakeibo.transactions + DROP COLUMN article_id; COMMIT; diff --git a/revert/transactions@v1.0.0-alpha.1.sql b/revert/transactions@v1.0.0-alpha.1.sql new file mode 100644 index 0000000..835ff3d --- /dev/null +++ b/revert/transactions@v1.0.0-alpha.1.sql @@ -0,0 +1,7 @@ +-- Revert kakeibo:transactions from pg + +BEGIN; + +DROP TABLE kakeibo.transactions; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index 4e6164d..a3f99dc 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -15,3 +15,4 @@ items_update_timestamp [items update_timestamp] 2023-03-12T14:14:13Z Masaya Tojo @v1.0.0-alpha.1 2023-03-12T14:21:52Z Masaya Tojo <masaya@tojo.tokyo> # Tag v1.0.0-alpha.1. articles [schema] 2023-03-12T14:43:06Z Masaya Tojo <masaya@tojo.tokyo> # Add table to manage articles. +transactions [transactions@v1.0.0-alpha.1 articles] 2023-03-12T15:06:03Z Masaya Tojo <masaya@tojo.tokyo> # Add article_id column to transactions table. diff --git a/verify/transactions.sql b/verify/transactions.sql index 0cc1b2d..3f5b58f 100644 --- a/verify/transactions.sql +++ b/verify/transactions.sql @@ -7,7 +7,8 @@ SELECT id, date, note, created_at, - updated_at + updated_at, + article_id FROM kakeibo.transactions WHERE FALSE; diff --git a/verify/transactions@v1.0.0-alpha.1.sql b/verify/transactions@v1.0.0-alpha.1.sql new file mode 100644 index 0000000..0cc1b2d --- /dev/null +++ b/verify/transactions@v1.0.0-alpha.1.sql @@ -0,0 +1,14 @@ +-- Verify kakeibo:transactions on pg + +BEGIN; + +SELECT id, + type_code, + date, + note, + created_at, + updated_at + FROM kakeibo.transactions + WHERE FALSE; + +ROLLBACK; |