CREATE TABLE bank_refinancing_policies (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    bank_id INT UNSIGNED NOT NULL,
    min_installments INT UNSIGNED NULL,
    min_paid_installments INT UNSIGNED NULL,
    min_outstanding_balance DECIMAL(15,2) NULL,
    min_installment_amount DECIMAL(12,2) NULL,
    min_change_amount DECIMAL(12,2) NULL,
    status ENUM('ativo','inativo') NOT NULL DEFAULT 'ativo',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    CONSTRAINT uniq_bank_refinancing_policy UNIQUE (bank_id),
    CONSTRAINT fk_bank_refinancing_bank FOREIGN KEY (bank_id) REFERENCES bank_catalog (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
