-- Migration: Add CD rates table to shared schema
-- For existing deployments that already have the shared schema initialized

CREATE TABLE IF NOT EXISTS shared.cd_rates (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    bank_name VARCHAR(255) NOT NULL,
    apy DECIMAL(6,4) NOT NULL,
    min_deposit DECIMAL(15,2),
    term VARCHAR(100) NOT NULL,
    term_months INTEGER,
    fetched_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    source_url VARCHAR(500),
    created_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_cd_rates_fetched ON shared.cd_rates(fetched_at DESC);
CREATE INDEX IF NOT EXISTS idx_cd_rates_apy ON shared.cd_rates(apy DESC);
