When you want to perform database migrations in rails you use the following command:
If you want to roll back your change you may need to find out what version your database is currently at and then roll back to a previous version:
To find the version use following command:
To roll back to previous version:
To use it to roll back your most recent migration simply run:
Other posts:
Difference between update_attribute and update_column
What is different in update_all, update, update_attribute, update_attributes methods of Active Record
Difference between .nil?, .empty?, .blank?, .present?
render vs redirect_to in Ruby on Rails
About
rake db:migrate
If you want to roll back your change you may need to find out what version your database is currently at and then roll back to a previous version:
To find the version use following command:
rake db:migration VERSION=?
To roll back to previous version:
rake db:migrate VERSION=<version to roll back to>
To use it to roll back your most recent migration simply run:
rake db:rollback
Other posts:
Difference between update_attribute and update_column
What is different in update_all, update, update_attribute, update_attributes methods of Active Record
Difference between .nil?, .empty?, .blank?, .present?
render vs redirect_to in Ruby on Rails
About
No comments:
Post a Comment