Issues with migrations in Ruby on Rails (09 feb 13)
The biggest problem I have encountered with migrations is this:
You add a field to a model. You add validation for that field. You write a migration that adds that column to the table corresponding to that model. It works in development and test. You send it to a customer who has code which is several versions old. They try to run several migrations. They break, because they load the new app with the new model, which refers to columns which don't exist in their old database.
== RenameLoginToEmail: migrating =============================================
Here's a workaround - db/migrate/20130211000000_rename_login_to_email.rb:
class RenameLoginToEmail < ActiveRecord::Migration
What's really needed is a way of tying migrations to source control. Checkout code version N. Run migration N. Checkout code version N+1. Run migration N+1 etc..