update money tracker
All checks were successful
Test and deploy staging / staging (push) Successful in 30s

This commit is contained in:
2026-09-23 18:06:20 +00:00
parent 2466db74cd
commit 499dd94cbb
9 changed files with 641 additions and 77 deletions

View File

@@ -3,11 +3,13 @@ CREATE TABLE IF NOT EXISTS money_accounts (
user_id text NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
name text NOT NULL,
opening_balance_cents integer NOT NULL DEFAULT 0,
kind text NOT NULL DEFAULT 'spendable',
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (user_id, name)
);
CREATE INDEX IF NOT EXISTS money_accounts_user_id_idx ON money_accounts (user_id);
ALTER TABLE money_accounts ADD COLUMN IF NOT EXISTS kind text NOT NULL DEFAULT 'spendable';
CREATE TABLE IF NOT EXISTS money_transactions (
id serial PRIMARY KEY,
@@ -28,11 +30,15 @@ CREATE TABLE IF NOT EXISTS money_recurring (
name text NOT NULL,
amount_cents integer NOT NULL,
cadence text NOT NULL,
starts_on date,
ends_on date,
account_id integer REFERENCES money_accounts(id) ON DELETE SET NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS money_recurring_user_id_idx ON money_recurring (user_id);
ALTER TABLE money_recurring ADD COLUMN IF NOT EXISTS starts_on date;
ALTER TABLE money_recurring ADD COLUMN IF NOT EXISTS ends_on date;
CREATE TABLE IF NOT EXISTS money_forecasts (
id serial PRIMARY KEY,
@@ -75,11 +81,28 @@ CREATE TABLE IF NOT EXISTS money_wishlist (
user_id text NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
name text NOT NULL,
estimated_cents integer,
priority integer NOT NULL DEFAULT 3,
notes text,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS money_wishlist_user_id_idx ON money_wishlist (user_id);
ALTER TABLE money_wishlist ADD COLUMN IF NOT EXISTS priority integer NOT NULL DEFAULT 3;
CREATE TABLE IF NOT EXISTS money_projection_settings (
id serial PRIMARY KEY,
user_id text NOT NULL UNIQUE REFERENCES "user"(id) ON DELETE CASCADE,
investment_account_id integer REFERENCES money_accounts(id) ON DELETE SET NULL,
reserve_cents integer NOT NULL DEFAULT 100000,
annual_return_percent numeric(5, 2) NOT NULL DEFAULT 5.00,
contribution_mode text NOT NULL DEFAULT 'excess',
include_recurring integer NOT NULL DEFAULT 1,
fixed_monthly_cents integer NOT NULL DEFAULT 0,
end_date date,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE money_projection_settings ADD COLUMN IF NOT EXISTS include_recurring integer NOT NULL DEFAULT 1;
CREATE TABLE IF NOT EXISTS money_insurances (
id serial PRIMARY KEY,