How To Run Migrations And Migration Actions From The Rails Console

Posted by Weston Ganger

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 railsmigrations

Recommended Posts



Westonganger profile

Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected