chore: commit previously untracked runtime files (splits, auth, participants, shared)

This commit is contained in:
2026-03-08 18:00:46 +11:00
parent 30a7857d13
commit 5dbeb0cb87
11 changed files with 450 additions and 0 deletions
@@ -0,0 +1,19 @@
CREATE TABLE IF NOT EXISTS participants (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ DEFAULT NOW()
);
INSERT INTO participants (name) VALUES ('Me') ON CONFLICT DO NOTHING;
CREATE TABLE IF NOT EXISTS transaction_splits (
id SERIAL PRIMARY KEY,
transaction_id INTEGER NOT NULL REFERENCES transactions(id) ON DELETE CASCADE,
participant_id INTEGER NOT NULL REFERENCES participants(id) ON DELETE CASCADE,
share_percent NUMERIC(5,2) NOT NULL CHECK (share_percent > 0 AND share_percent <= 100),
settled BOOLEAN DEFAULT FALSE,
settled_at TIMESTAMPTZ,
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE (transaction_id, participant_id)
);
CREATE INDEX IF NOT EXISTS idx_splits_txn ON transaction_splits(transaction_id);
CREATE INDEX IF NOT EXISTS idx_splits_participant ON transaction_splits(participant_id);
@@ -0,0 +1,17 @@
-- Add email to participants for OAuth identity mapping
ALTER TABLE participants ADD COLUMN IF NOT EXISTS email TEXT UNIQUE;
-- Add owner_id and account_holder_name to statements
ALTER TABLE statements ADD COLUMN IF NOT EXISTS owner_id INTEGER NOT NULL DEFAULT 1 REFERENCES participants(id);
ALTER TABLE statements ADD COLUMN IF NOT EXISTS account_holder_name TEXT;
CREATE INDEX IF NOT EXISTS idx_statements_owner_id ON statements(owner_id);
-- Auto-assignment mapping table: (bank_name, account_number) -> owner
CREATE TABLE IF NOT EXISTS account_owner_mappings (
id SERIAL PRIMARY KEY,
bank_name TEXT NOT NULL,
account_number TEXT NOT NULL,
owner_id INTEGER NOT NULL REFERENCES participants(id),
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(bank_name, account_number)
);