aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2023-02-28 00:56:45 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2023-03-01 02:28:55 +0900
commit54e3c3f3e15a01b4ebf6ed43cc4b64cfba59ff36 (patch)
tree6e23655134080377a3ed2564e9317b2dc0d59abd
parentb7b17d87df7e70d6774e40b864227fc3ddce4686 (diff)
Add table for tracking transactions.
-rw-r--r--deploy/transactions.sql16
-rw-r--r--revert/transactions.sql7
-rw-r--r--sqitch.plan1
-rw-r--r--verify/transactions.sql14
4 files changed, 38 insertions, 0 deletions
diff --git a/deploy/transactions.sql b/deploy/transactions.sql
new file mode 100644
index 0000000..0a1d7eb
--- /dev/null
+++ b/deploy/transactions.sql
@@ -0,0 +1,16 @@
+-- Deploy kakeibo:transactions to pg
+-- requires: appschema
+-- requires: transaction_type
+
+BEGIN;
+
+CREATE TABLE kakeibo.transactions (
+ id SERIAL PRIMARY KEY,
+ type kakeibo.transaction_type NOT NULL,
+ 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
new file mode 100644
index 0000000..835ff3d
--- /dev/null
+++ b/revert/transactions.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 8d4f9fd..8a0eab8 100644
--- a/sqitch.plan
+++ b/sqitch.plan
@@ -4,3 +4,4 @@
appschema 2023-02-26T06:27:59Z Masaya Tojo <masaya@tojo.tokyo> # Add schema for all kakeibo objects.
transaction_type [appschema] 2023-02-27T15:51:38Z Masaya Tojo <masaya@tojo.tokyo> # Add transaction type.
+transactions [appschema transaction_type] 2023-02-27T15:53:02Z Masaya Tojo <masaya@tojo.tokyo> # Add table for tracking transactions.
diff --git a/verify/transactions.sql b/verify/transactions.sql
new file mode 100644
index 0000000..47d5982
--- /dev/null
+++ b/verify/transactions.sql
@@ -0,0 +1,14 @@
+-- Verify kakeibo:transactions on pg
+
+BEGIN;
+
+SELECT id,
+ type,
+ date,
+ note,
+ created_at,
+ updated_at
+ FROM kakeibo.transactions
+ WHERE FALSE;
+
+ROLLBACK;