Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Very good question. Had me stumped so I dove into the rails source and pulled up <a href="https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/databases.rake#L402" rel="noreferrer"><code>database.rake</code></a>. Now it's more clear:</p> <p><code>db:test:clone</code> is just a combination of <code>db:schema:dump</code> and <code>db:test:load</code>:</p> <pre><code>task :clone =&gt; %w(db:schema:dump db:test:load) </code></pre> <p><code>db:test:clone_structure</code> uses the {rails_env}_structure.sql file:</p> <pre><code>task :clone_structure =&gt; [ '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 </code></pre> <p><code>db:test:load</code> is the same as <code>db:schema:load</code>, but invokes it on the test database:</p> <pre><code>task :load =&gt; 'db:test:purge' do ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) # ... db_namespace['schema:load'].invoke end </code></pre> <p><code>db:test:prepare</code> alerts you if any migrations are pending, and if not, either runs <code>db:test:clone_structure</code> (using the {rails_env}_structure.sql file) or <code>db:test:load</code> (using the schema.rb file), depending on the schema format (this is a little confusing to me, maybe someone else can expand on it):</p> <pre><code>task :prepare =&gt; 'db:abort_if_pending_migrations' do # ... db_namespace[{ :sql =&gt; 'test:clone_structure', :ruby =&gt; 'test:load' }[ActiveRecord::Base.schema_format]].invoke end </code></pre> <p>Hope this clears it up! Again, going through the <a href="https://github.com/rails/rails/blob/master/activerecord/lib/active_record/railties/databases.rake#L402" rel="noreferrer">database.rake</a> file is easy and will clear up any other questions you might have. That link goes to the line that is the beginning of the :test namespace.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload