Difference between rake db:migrate db:reset and db:schema:load

后端 未结 5 778
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 11:48

The difference between rake db:migrate and rake db:reset is pretty clear in my head. The thing which I don\'t understand is how rake db:schem

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 12:09

    You could simply look in the Active Record Rake tasks as that is where I believe they live as in this file. https://github.com/rails/rails/blob/fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2/activerecord/lib/active_record/tasks/database_tasks.rb

    What they do is your question right?

    That depends on where they come from and this is just and example to show that they vary depending upon the task. Here we have a different file full of tasks.

    https://github.com/rails/rails/blob/fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2/activerecord/Rakefile

    which has these tasks.

    namespace :db do
      task create: ["db:mysql:build", "db:postgresql:build"]
      task drop: ["db:mysql:drop", "db:postgresql:drop"]
    end
    

    This may not answer your question but could give you some insight into go ahead and look the source over especially the rake files and tasks. As they do a pretty good job of helping you use rails they don't always document the code that well. We could all help there if we know what it is supposed to do.

提交回复
热议问题