Reset the database (purge all), then seed a database

后端 未结 6 965
感情败类
感情败类 2021-01-29 18:09

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?

6条回答
  •  渐次进展
    2021-01-29 18:20

    You can delete everything and recreate database + seeds with both:

    1. rake db:reset: loads from schema.rb
    2. rake db:drop db:create db:migrate db:seed: loads from migrations

    Make sure you have no connections to db (rails server, sql client..) or the db won't drop.

    schema.rb is a snapshot of the current state of your database generated by:

    rake db:schema:dump
    

提交回复
热议问题