-- 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;
