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 ActiveRecord::Migrator.migrate('db/migrate') # To rollback 3 migrations ActiveRecord::Migrator.rollback('db/migrate', 3)
Related External Links: