How To Run Migrations And Migration Actions From The Rails Console

Posted by Weston Ganger on February 14, 2017

Sometimes you may need to fix your database by running the some migration commands in the console or in your code. Heres how to do so.

# To run single migration actions
ActiveRecord::Migration.add_column(:table_name, :column_name, :integer)

# To run all migrations

# To rollback 3 migrations
ActiveRecord::Migrator.rollback('db/migrate', 3)

Related External Links:

Posted in Rails and Tagged with rails migrations 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts