-- Tabela de cache de saldo Open Banking
CREATE TABLE IF NOT EXISTS openbanking_saldo_cache (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    conta_id INT UNSIGNED NOT NULL,
    saldo_atual DECIMAL(15,2) NOT NULL DEFAULT 0,
    saldo_disponivel DECIMAL(15,2) NOT NULL DEFAULT 0,
    cached_at DATETIME NOT NULL,
    INDEX idx_conta (conta_id),
    INDEX idx_cached_at (cached_at),
    UNIQUE KEY uk_conta (conta_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

