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;