CRUD de contas (corrente/poupança/investimento/cartão) com saldo calculado automaticamente. account_id nullable em transactions. Widget patrimônio no dashboard. Tela /contas. Seletor de conta nas transações manuais. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
15 lines
665 B
SQL
15 lines
665 B
SQL
CREATE TABLE IF NOT EXISTS accounts (
|
|
id SERIAL PRIMARY KEY,
|
|
name VARCHAR(100) NOT NULL,
|
|
type VARCHAR(20) NOT NULL DEFAULT 'checking'
|
|
CHECK (type IN ('checking', 'savings', 'investment', 'credit')),
|
|
initial_balance NUMERIC(12, 2) NOT NULL DEFAULT 0,
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
ALTER TABLE transactions ADD COLUMN IF NOT EXISTS account_id INTEGER
|
|
REFERENCES accounts (id) ON DELETE SET NULL;
|
|
|
|
INSERT INTO schema_migrations (version) VALUES (4) ON CONFLICT DO NOTHING;
|