aboutsummaryrefslogtreecommitdiff
path: root/deploy/items.sql
blob: 0fd79e98c6caf66ad04d410e03c01127890e1e78 (about) (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: appschema
-- 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,
  amount INTEGER NOT NULL CHECK (amount > 0),
  note TEXT,
  created_at TIMESTAMP NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);

COMMIT;