ankane / strong_migrations

Catch unsafe migrations in development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignore columns rule doesn't warn you about multiple columns in a migration to drop more than one

lake-effect opened this issue · comments

Steps to reproduce

  1. Write a migration in Rails and create a table with 3 or more columns
  2. Include strong_migrations in your application config appropriately
  3. Write a migration dropping 2 of those columns the usual way: 2 invocations of remove_column, :column_name in the migration
  4. Run the migration
  5. Observe that strong_migrations only warns you about ignoring the first column

Expected behavior

Step 5 should mention both columns being dropped.

Environment

  • strong_migrations 1.3.2
  • rails 7.0.4.3

Hi @lake-effect, Strong Migrations errors on the first unsafe statement it encounters, so it doesn't know about future statements. Other approaches like parsing the migration file could probably detect this, but I don't think it's worth changing approaches.

That makes sense. Maybe an effective thing to do in that case is add a notice in the output like Re-run the migration after making the recommended changes to detect other issues.