Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Showing a Rails migration bug

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 db
Octocat-spinner-32 doc
Octocat-spinner-32 lib
Octocat-spinner-32 log
Octocat-spinner-32 public
Octocat-spinner-32 script
Octocat-spinner-32 test
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 config.ru
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.

Something went wrong with that request. Please try again.