SET @column_exists := (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
      AND TABLE_NAME = 'bank_refinancing_policies'
      AND COLUMN_NAME = 'min_change_amount'
);

SET @ddl := IF(
    @column_exists = 0,
    'ALTER TABLE bank_refinancing_policies ADD COLUMN min_change_amount DECIMAL(12,2) NULL AFTER min_installment_amount',
    'SELECT 1'
);

PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
