Saturday, December 13, 2014

Rails: running a particular migration

This is an old Stackoverflow question - http://stackoverflow.com/questions/753919/run-a-single-migration-file


If the migration file is:
--
db/migrate/20141211192127_add_col1_to_table1.rb

class AddCol1ToTable1 < ActiveRecord::Migration
  def change
    add_column :table1, :col1, :boolean
  end
end
--

Then, we have to do the following in Rails console:

> require Rails.root + "db/migrate/20141211192127_add_col1_to_table1.rb"

> AddCol1ToTable1.new.migrate(:up)

No comments:

Post a Comment

Followers

Blog Archive