Files
finance-app/prisma/migrations/0006_budgets/migration.sql
T
siddharthd d455738732 feat(finance): Phase 6 — Budget & Analytics
Add monthly budgets per category with spend-vs-budget dashboard and 6-month trend table.
Includes upsert budget API, monthly analytics endpoint, inline budget editing, and route auth fixes.
2026-03-08 16:57:33 +11:00

12 lines
406 B
SQL

CREATE TABLE IF NOT EXISTS budgets (
id SERIAL PRIMARY KEY,
owner_id INTEGER NOT NULL REFERENCES participants(id),
category TEXT NOT NULL,
month DATE NOT NULL,
amount_limit NUMERIC(10,2) NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(owner_id, category, month)
);
CREATE INDEX IF NOT EXISTS idx_budgets_owner_month ON budgets(owner_id, month);