diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2023-02-28 21:40:20 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-02 09:22:36 +0900 |
commit | 0854294b374660178c3d62a75bdd9a554359dcb4 (patch) | |
tree | 278bc3b01af815004545d8cb33c0afc09a1a2ab4 /deploy/items.sql | |
parent | 343155aab78c28d6d09bea75671b390aec9599f6 (diff) |
Add items table for tracking individual products in transaction.
Diffstat (limited to 'deploy/items.sql')
-rw-r--r-- | deploy/items.sql | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/deploy/items.sql b/deploy/items.sql new file mode 100644 index 0000000..0fd79e9 --- /dev/null +++ b/deploy/items.sql @@ -0,0 +1,18 @@ +-- Deploy kakeibo:items to pg +-- requires: appschema +-- 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, + amount INTEGER NOT NULL CHECK (amount > 0), + note TEXT, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +COMMIT; |