SET @column_exists := (
    SELECT COUNT(*)
    FROM information_schema.columns
    WHERE table_schema = DATABASE()
      AND table_name = 'bank_portability_policies'
      AND column_name = 'min_installment_amount'
);

SET @ddl_statement := IF(
    @column_exists = 0,
    'ALTER TABLE bank_portability_policies ADD COLUMN min_installment_amount DECIMAL(12,2) NULL AFTER min_outstanding_balance',
    'DO 0'
);

PREPARE portability_stmt FROM @ddl_statement;
EXECUTE portability_stmt;
DEALLOCATE PREPARE portability_stmt;
