summaryrefslogtreecommitdiff
path: root/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'deploy')
-rw-r--r--deploy/transactions.sql20
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;