-- Add merchant_normalized column to existing transactions table
ALTER TABLE transactions ADD COLUMN IF NOT EXISTS merchant_normalized TEXT;

-- Create transaction_overrides table
CREATE TABLE IF NOT EXISTS transaction_overrides (
    id SERIAL PRIMARY KEY,
    transaction_id INTEGER NOT NULL UNIQUE REFERENCES transactions(id) ON DELETE CASCADE,
    merchant_normalized TEXT,
    category_override TEXT,
    notes TEXT,
    updated_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_overrides_txn_id ON transaction_overrides(transaction_id);
