aboutsummaryrefslogtreecommitdiff
path: root/deploy/items.sql
blob: 0a43f8bfe1d6abeb56d73333de66f5ad5e62b287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- Deploy kakeibo:items to pg
-- requires: schema
-- 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 CHECK (note <> ''),
  amount INTEGER NOT NULL CHECK (amount > 0),
  note TEXT CHECK (note <> '') ,
  created_at TIMESTAMP NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);

COMMIT;