Purge or recreate a Ruby on Rails database

前端 未结 19 1290
清酒与你
清酒与你 2020-11-28 17:01

I have a dev Ruby on Rails database full of data. I want to delete everything and rebuild the database. I\'m thinking of using something like:

rake db:recrea         


        
19条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 17:27

    Use like

    rake db:drop db:create db:migrate db:seed
    

    All in one line. This is faster since the environment doesn't get reloaded again and again.

    db:drop - will drop database.

    db:create - will create database (host/db/password will be taken from config/database.yml)

    db:migrate - will run existing migrations from directory (db/migration/.rb)*.

    db:seed - will run seed data possible from directory (db/migration/seed.rb)..

    I usually prefer:

    rake db:reset
    

    to do all at once.

    Cheers!

提交回复
热议问题