feat(#21): contas bancárias e patrimônio consolidado
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]>
This commit is contained in:
@@ -17,8 +17,11 @@ var m002 string
|
||||
//go:embed sql/003_recurring_ignores.sql
|
||||
var m003 string
|
||||
|
||||
//go:embed sql/004_accounts.sql
|
||||
var m004 string
|
||||
|
||||
func Run(ctx context.Context, pool *pgxpool.Pool) error {
|
||||
migrations := []string{m001, m002, m003}
|
||||
migrations := []string{m001, m002, m003, m004}
|
||||
for i, sql := range migrations {
|
||||
if _, err := pool.Exec(ctx, sql); err != nil {
|
||||
return fmt.Errorf("migration %03d: %w", i+1, err)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user