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:schema:load
different from the former two.
Just to be sure that I am on the same page:
rake db:migrate
- Runs the migrations which haven't been run yet.rake db:reset
- Clears the database (presumably does a rake db:drop
+ rake db:create
+ rake db:migrate
) and runs migration on a fresh database.Please help to clarify, if my understanding has gone wrong.
db:schema:load creates tables and columns within the (existing) database following schema.rb
db:setup does db:create, db:schema:load, db:seed
Typically, you would use db:migrate after having made changes to the schema via new migration files (this makes sense only if there is already data in the database). db:schema:load is used when you setup a new instance of your app.
I hope that helps.
UPDATE for rails 3.2.12:
I just checked the source and the dependencies are like this now:
db:schema:dump dumps the current env's schema (and seems to create the db as well)
db:setup runs db:schema:load, db:seed
For further information please have a look at https://github.com/rails/rails/blob/v3.2.12/activerecord/lib/active_record/railties/databases.rake (for Rails 3.2.x) and https://github.com/rails/rails/blob/v4.0.5/activerecord/lib/active_record/railties/databases.rake (for Rails 4.0.x)