-- Schema bootstrap. Runs only once, when the data volume is empty
-- (postgres official image executes /docker-entrypoint-initdb.d/ files on first init).

CREATE TABLE IF NOT EXISTS expenses (
    id          SERIAL PRIMARY KEY,
    amount      NUMERIC(12,2) NOT NULL,
    category    TEXT NOT NULL,
    note        TEXT,
    spent_at    DATE NOT NULL,
    created_at  TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS expenses_spent_at_idx ON expenses (spent_at DESC);
