diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2023-08-31 00:35:36 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2023-10-13 02:13:22 +0900 |
commit | e3131b37eb7d9b6284a68077a9f0d5ad9dc99f98 (patch) | |
tree | 16bb962bbbe566b24e985c4886570d498a62c009 /deploy | |
parent | 67cabf314b2b60c81454682f9259c3c207f71a73 (diff) |
Add table to manage transactions
Diffstat (limited to 'deploy')
-rw-r--r-- | deploy/transactions.sql | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/deploy/transactions.sql b/deploy/transactions.sql new file mode 100644 index 0000000..3f21eb7 --- /dev/null +++ b/deploy/transactions.sql @@ -0,0 +1,20 @@ +-- Deploy photos:transactions to pg +-- requires: schema +-- requires: photos + +BEGIN; + +SET search_path to photos; + +CREATE TABLE transactions( + id UUID PRIMARY KEY, + photo_id UUID NOT NULL REFERENCES photos(id) ON DELETE RESTRICT ON UPDATE RESTRICT, + is_income BOOLEAN NOT NULL DEFAULT FALSE, + category TEXT NOT NULL CHECK (category <> ''), + amount INTEGER NOT NULL CHECK (amount > 0), + note TEXT CHECK (note <> ''), + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +COMMIT; |