How To Run Migrations And Migration Actions From The Rails Console

Posted by Weston Ganger

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
ActiveRecord::Migrator.migrate('db/migrate')

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


Related External Links:

Article Topic:Software Development - Rails

Date:February 14, 2017

Recommended Posts

Contact

604-309-8713
info@solidfoundationwebdev.com

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