Instead of flipping values around by hand and possibly making mistakes, simply put an ‘un’ before them
Usage
class RenameStuff < ActiveRecord::Migration def self.up rename_column :users, :username, :login rename_column :users, :e_mail, :email end def self.down # simply cody and add 'un' unrename_column :users, :username, :login unrename_column :users, :e_mail, :email end end
Code
# convenience method, so that rename statements do not need to be reversed by hand class ActiveRecord::ConnectionAdapters::Table def unrename(a,b) rename b,a end end module ActiveRecord::ConnectionAdapters::SchemaStatements def unrename_column(table_name, a, b) rename_column(table_name, b, a) end end
rails-vim gives the great command :Rinvert which just inverts every migration.
thanks for the tipp, i think textmate has something similar too(maybe a plugin…)