summaryrefslogtreecommitdiff
path: root/deploy/transactions.sql
blob: 3f21eb702802241703cc4ed39d89310299773e7b (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;