Purge or recreate a Ruby on Rails database

前端 未结 19 1161
清酒与你
清酒与你 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:48

    Because in development , you will always want to recreate the database,you can define a rake task in your lib/tasks folder like that.

      namespace :db do
          task :all => [:environment, :drop, :create, :migrate] do
       end 
    end
    

    and in terminal you will run

    rake db:all
    

    it will rebuild your database

    0 讨论(0)
提交回复
热议问题