aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2023-03-12 15:46:32 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2023-03-12 23:38:12 +0900
commitcd23d52c0c5c3d3264c5a8706c2c6fe2b1649640 (patch)
treeec38121810fb9edd839dd25812a1f46c213213fd
parent55618dcd6a40c0b85612a20994114a18987ff43d (diff)
Add table for tracking items.
-rw-r--r--deploy/items.sql18
-rw-r--r--revert/items.sql7
-rw-r--r--sqitch.plan1
-rw-r--r--verify/items.sql16
4 files changed, 42 insertions, 0 deletions
diff --git a/deploy/items.sql b/deploy/items.sql
new file mode 100644
index 0000000..0a43f8b
--- /dev/null
+++ b/deploy/items.sql
@@ -0,0 +1,18 @@
+-- Deploy kakeibo:items to pg
+-- requires: schema
+-- requires: transactions
+
+BEGIN;
+
+CREATE TABLE kakeibo.items (
+ id SERIAL PRIMARY KEY,
+ transaction_id INTEGER NOT NULL REFERENCES kakeibo.transactions(id) ON DELETE RESTRICT ON UPDATE RESTRICT,
+ category TEXT NOT NULL,
+ subcategory TEXT CHECK (note <> ''),
+ amount INTEGER NOT NULL CHECK (amount > 0),
+ note TEXT CHECK (note <> '') ,
+ created_at TIMESTAMP NOT NULL DEFAULT NOW(),
+ updated_at TIMESTAMP NOT NULL DEFAULT NOW()
+);
+
+COMMIT;
diff --git a/revert/items.sql b/revert/items.sql
new file mode 100644
index 0000000..b36bf6b
--- /dev/null
+++ b/revert/items.sql
@@ -0,0 +1,7 @@
+-- Revert kakeibo:items from pg
+
+BEGIN;
+
+DROP TABLE kakeibo.items;
+
+COMMIT;
diff --git a/sqitch.plan b/sqitch.plan
index bd18863..5cf4710 100644
--- a/sqitch.plan
+++ b/sqitch.plan
@@ -4,3 +4,4 @@
schema 2023-03-11T15:56:41Z Masaya Tojo <masaya@tojo.tokyo> # Add schema for use in kakeibo.
transactions [schema] 2023-03-11T16:50:25Z Masaya Tojo <masaya@tojo.tokyo> # Add table for tracking transactions.
+items [schema transactions] 2023-03-12T04:48:30Z Masaya Tojo <masaya@tojo.tokyo> # Add table for tracking items.
diff --git a/verify/items.sql b/verify/items.sql
new file mode 100644
index 0000000..9a561cf
--- /dev/null
+++ b/verify/items.sql
@@ -0,0 +1,16 @@
+-- Verify kakeibo:items on pg
+
+BEGIN;
+
+SELECT id,
+ transaction_id,
+ category,
+ subcategory,
+ amount,
+ note,
+ created_at,
+ updated_at
+ FROM kakeibo.items
+ WHERE FALSE;
+
+ROLLBACK;