Is there a rake command to wipe out the data in the database tables?
How do I create a db:seed script to pre-fill data to my tables?
You can use rake db:reset
when you want to drop the local database and start fresh with data loaded from db/seeds.rb
. This is a useful command when you are still figuring out your schema, and often need to add fields to existing models.
Once the reset command is used it will do the following:
Drop the database: rake db:drop
Load the schema: rake db:schema:load
Seed the data: rake db:seed
But if you want to completely drop your database you can use rake db:drop
. Dropping the database will also remove any schema conflicts or bad data. If you want to keep the data you have, be sure to back it up before running this command.
This is a detailed article about the most important rake database commands.