You will need to admit, to some newbie to rails and databases, the state explanation on makes all of those tasks seem the identical. Quote:

rake db:test:clone  Recreate the test database from
                    the current environment’s database schema

rake db:test:clone_structure    Recreate the test database from the
                                development structure

rake db:test:load   Recreate the test database from the current schema.rb

rake db:test:prepare    Check for pending migrations and load the test schema

I do not know the main difference between structure and schema. And what's the main difference between loading the present environment's schema and merely loading schema.rb?

Precisely how similar (or different) are these tasks?

Excellent question. Had me stumped and so i dove in to the rails source and drawn up [cde]. Now it's more obvious:

database.rake is simply a mixture of db:test:clone and db:schema:dump:


task :clone => %w(db:schema:dump db:test:load) uses the _structure.sql file:


task :clone_structure => [ 'db:structure:dump', 'db:test:purge' ] do # skipped some code, here's what happens for MySQL: ActiveRecord::Base.establish_connection(:test) # ... IO.readlines("#{Rails.root}/db/#{Rails.env}_structure.sql").join.split("\n\n").each do |table| ActiveRecord::Base.connection.execute(table) end end is equivalent to db:test:load, but creates it around the test database:


task :load => 'db:test:purge' do ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) # ... db_namespace['schema:load'].invoke end alerts you if any migrations are pending, and when not, either runs db:test:prepare (while using _structure.sql file) or db:test:clone_structure (while using schema.rb file), with respect to the schema format (this can be a little confusing in my experience, maybe another person can expand onto it):


Hope this clears up! Again, studying the database.rake file is simple and can obvious up every other questions you may have. That link would go to the road that's the start of the :test namespace.