Reputation: 3256
I'm beginner in Ruby on Rails. I dropped my table. But I have the files in the db/migrate
folder. How can I get back my table from those migrate files?
Upvotes: 0
Views: 36
Reputation: 76784
According to this question, you should be able to do the following:
rake db:create #-> creates DB based on the schema file
rake db:migrate #-> populates the db with the various changes in the migrations
If you follow these steps, with nathanvda's
advice, you should be able to solve the issue you're seeing!
Upvotes: 0
Reputation: 50057
The ideal way to do this, is using
rake db:setup
This will recreate the database and load the schema into the development database. With every migration rails keeps the current state of the database in schema.rb
(or structure.sql
), and it uses those to efficiently recreate the last state.
If you have pending migrations, you will have to do rake db:migrate
, but this will take more time, since it will redo every step as before.
Also note in some cases it is not possible to run the migrations from the start again, and imho that is not the intention of the migrations.
Upvotes: 1