diff options
| -rw-r--r-- | deploy/kakeibo.transactions.sql | 9 | ||||
| -rw-r--r-- | deploy/kakeibo.transactions@v1.0.0-alpha.4.sql | 12 | ||||
| -rw-r--r-- | revert/kakeibo.transactions.sql | 8 | ||||
| -rw-r--r-- | revert/kakeibo.transactions@v1.0.0-alpha.4.sql | 8 | ||||
| -rw-r--r-- | sqitch.plan | 1 | ||||
| -rw-r--r-- | verify/kakeibo.transactions.sql | 2 | ||||
| -rw-r--r-- | verify/kakeibo.transactions@v1.0.0-alpha.4.sql | 15 | 
7 files changed, 49 insertions, 6 deletions
| diff --git a/deploy/kakeibo.transactions.sql b/deploy/kakeibo.transactions.sql index 0572a23..6e0787f 100644 --- a/deploy/kakeibo.transactions.sql +++ b/deploy/kakeibo.transactions.sql @@ -2,11 +2,14 @@  -- requires: schema  -- requires: articles +  BEGIN; +ALTER TABLE kakeibo.transactions RENAME COLUMN type_code TO type;  ALTER TABLE kakeibo.transactions -  ADD COLUMN article_id INTEGER, -  ADD CONSTRAINT transactions_article_id_fkey -  FOREIGN KEY (article_id) REFERENCES kakeibo.articles (id); +  ALTER COLUMN type TYPE kakeibo.transaction_type +  USING CASE type WHEN 0 +  THEN 'outgo'::kakeibo.transaction_type +  ELSE 'income'::kakeibo.transaction_type END;  COMMIT; diff --git a/deploy/kakeibo.transactions@v1.0.0-alpha.4.sql b/deploy/kakeibo.transactions@v1.0.0-alpha.4.sql new file mode 100644 index 0000000..0572a23 --- /dev/null +++ b/deploy/kakeibo.transactions@v1.0.0-alpha.4.sql @@ -0,0 +1,12 @@ +-- Deploy kakeibo:transactions to pg +-- requires: schema +-- requires: articles + +BEGIN; + +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/revert/kakeibo.transactions.sql b/revert/kakeibo.transactions.sql index d30390a..a31898f 100644 --- a/revert/kakeibo.transactions.sql +++ b/revert/kakeibo.transactions.sql @@ -1,8 +1,12 @@ --- Revert kakeibo:transactions from pg +-- Deploy kakeibo:transactions to pg +-- requires: schema +-- requires: articles  BEGIN; +ALTER TABLE kakeibo.transactions RENAME COLUMN type TO type_code;  ALTER TABLE kakeibo.transactions -  DROP COLUMN article_id; +  ALTER COLUMN type_code TYPE integer +  USING CASE type_code WHEN 'outgo' THEN 0 ELSE 1 END;  COMMIT; diff --git a/revert/kakeibo.transactions@v1.0.0-alpha.4.sql b/revert/kakeibo.transactions@v1.0.0-alpha.4.sql new file mode 100644 index 0000000..d30390a --- /dev/null +++ b/revert/kakeibo.transactions@v1.0.0-alpha.4.sql @@ -0,0 +1,8 @@ +-- Revert kakeibo:transactions from pg + +BEGIN; + +ALTER TABLE kakeibo.transactions +  DROP COLUMN article_id; + +COMMIT; diff --git a/sqitch.plan b/sqitch.plan index 54ded53..f353f40 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -29,3 +29,4 @@ photo.photos [photo] 2023-03-27T16:00:51Z Masaya Tojo <masaya@tojo.tokyo> # Add  @v1.0.0-alpha.4 2023-04-08T04:58:15Z Masaya Tojo <masaya@tojo.tokyo> # Tag v1.0.0-alpha.4  kakeibo.transaction_type [kakeibo] 2023-04-08T05:28:15Z Masaya Tojo <masaya@tojo.tokyo> # Add `transaction_type` enum type. +kakeibo.transactions [kakeibo.transactions@v1.0.0-alpha.4 kakeibo.transaction_type] 2023-04-08T05:50:31Z Masaya Tojo <masaya@tojo.tokyo> # Rename type_code column to type and change data type from integer to transaction_type. diff --git a/verify/kakeibo.transactions.sql b/verify/kakeibo.transactions.sql index 3f5b58f..3dc2a9a 100644 --- a/verify/kakeibo.transactions.sql +++ b/verify/kakeibo.transactions.sql @@ -3,7 +3,7 @@  BEGIN;  SELECT id, -       type_code, +       type,         date,         note,         created_at, diff --git a/verify/kakeibo.transactions@v1.0.0-alpha.4.sql b/verify/kakeibo.transactions@v1.0.0-alpha.4.sql new file mode 100644 index 0000000..3f5b58f --- /dev/null +++ b/verify/kakeibo.transactions@v1.0.0-alpha.4.sql @@ -0,0 +1,15 @@ +-- Verify kakeibo:transactions on pg + +BEGIN; + +SELECT id, +       type_code, +       date, +       note, +       created_at, +       updated_at, +       article_id +  FROM kakeibo.transactions + WHERE FALSE; + +ROLLBACK; | 
