How to recognize migration direction (up or down) with Rails 3 style migrations (def change)?

Just for future reference, for Rails 4 the best way to do this is to use reversible:

def change
  # ...change code...

  reversible do |dir|
    dir.up do
      # ...up-only code...
    end
  end
end

See http://guides.rubyonrails.org/migrations.html#using-reversible

Leave a Comment