Migrations overview
| File | What it adds |
|---|---|
001_initial_schema.sql | Core tables, RLS policies, indexes |
002_seed_data.sql | Demo data for new accounts |
003_accounts_advanced.sql | Auth trigger, seed remap function |
004_transfers.sql | transfer_id column on transactions |
005_rag_embeddings.sql | pgvector extension, user_embeddings table, hybrid search |
011_rag_fcm.sql | Transaction embeddings (1024-dim), FCM tokens, FTS search vector, pg_cron |
012_rag_search.sql | FTS + semantic search functions |
Core tables
users
auth.users insert. preferred_currency drives all display formatting in the Flutter app.
accounts
livery_color drives the card gradient on the Accounts Hub screen. statement_day is used for the credit card billing cycle calculation in balance reconciliation.
transactions
holdings
budgets
groups and debts
creditor_id and debtor_id are text (not uuid) to allow debts with non-registered contacts — a friend without a Vantage account can still appear as a party in a split.
bill_splits
user_insights
AI-generated insights written by the AnomalyAlerts agent. Read by the Dashboard’s real-time insights feed.
ai_conversations
user_embeddings
RAG memory store — daily/weekly/monthly financial summaries embedded at 384 dimensions (BAAI/bge-small-en-v1.5).
transaction_embeddings
Per-transaction semantic search — embedded at 1024 dimensions (Voyage 3-Lite).
fcm_tokens
Row-Level Security policies
All tables haveALTER TABLE ... ENABLE ROW LEVEL SECURITY. Key policy patterns:
PostgreSQL functions
handle_new_user() — auth trigger
Fires on every new auth.users insert. Creates a matching public.users row with name/avatar extracted from OAuth metadata: