CREATE TABLE bank_portability_policies (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    bank_destination_id INT UNSIGNED NOT NULL,
    bank_origin_id INT UNSIGNED NOT NULL,
    allows_purchase TINYINT(1) NOT NULL DEFAULT 0,
    min_installments INT UNSIGNED NULL,
    min_outstanding_balance DECIMAL(15,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_portability_pair UNIQUE (bank_destination_id, bank_origin_id),
    CONSTRAINT fk_bank_port_dest FOREIGN KEY (bank_destination_id) REFERENCES bank_catalog (id) ON DELETE CASCADE,
    CONSTRAINT fk_bank_port_origin FOREIGN KEY (bank_origin_id) REFERENCES bank_catalog (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
