How can I empty all the results in the database?
I have the db:seed
task which can add me initial data 开发者_如何学Goin the database. Is there anyway of clearing the database, so that it will remove all the contents of all the databases, but leave the tables there, so that I don't have to run all the migrations again?
If you re-setup a clean database, you shouldn't run the migrations, you should load the schema.rb
via db:schema:load
(bigger projects will have code in migrations that won't run anymore, for example because classes were renamed).
rake db:drop db:create db:schema:load db:seed
You can also run rake db:migrate:reset; rake db:seed
精彩评论