Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload schema.rb in rails app?

I currently have a few migrations which were created when I initially created models using rails generate model. I've run those migrations and successfully updated the database.

I've then made some changes to these migrations (not added new ones) because they were very small changes like a new column, or making a column unique, or adding an index.

But, even when I reset my db and run all migrations again, rails is insisting on using an outdated schema.rb file.

What should I be doing? How do I force a reload of this schema.rb?

like image 358
Damien Roche Avatar asked Apr 19 '12 02:04

Damien Roche


2 Answers

Provided you haven't pushed the code to production you can run rake db:rollback then rake db:migrate to drop and recreate the tables.

like image 63
Kevin Sylvestre Avatar answered Sep 23 '22 11:09

Kevin Sylvestre


Use this:

rake db:drop db:create db:migrate

like image 34
poustovitss Avatar answered Sep 26 '22 11:09

poustovitss