Showing a Rails migration bug
Ruby JavaScript CoffeeScript

README.rdoc

Migration bug

This is to demonstrate a bug in Rails migration, which causes newly added columns to not update.

Preparation for database:

  1. rake db:migrate

  2. rake db:seed

  3. rake db:rollback STEP=3

Now we have the item table in an initial state with data.

Step to produce error

  1. rake db:migrate

This would run the 3 migrations which causes the bug. Now you would see that the mode column is not updated

As a comparison, do the following:

  1. rake db:rollback STEP=3

  2. Change just_lookup.rb to be an empty migration OR add Item.reset_column_information at the end of that migration

  3. rake db:migrate

You would now see that the mode column is filled with values.

This shows just_lookup.rb should be related to the bug, and reset_column_information is not called for every migrations.