On Thu, Nov 6, 2008 at 1:07 PM, Greg H. <
[email protected]> wrote:
I’m still a bit confused - I’ll try to be more specific in questions:
- rake db:test:prepare - Check for pending migrations and load the test
schema
==> Q1. DOES NOT RUN IN PENDING MIGRATIONS TO TEST DATABASE?
Correct. It runs no migrations, period. It will abort if there are
pending
migrations for the development database.
==> Q2. RE TEST SCHEMA - ARE THE MIGRATIONS USE TO CREATE THE
DATABASE OR THE DEVELOPMENT SCHEMA FILE???
The development schema file, which db:test:prepare creates.
==> Q3. WHY DOES IT HAVE TO BE CALLED MORE THAN ONCE?
I didn’t know it did have to be called more than once.
- rake db:test:load - Recreate the test database from the current schema.rb
==> Q4. WHY DO WE NEED TO LOAD FROM THE SCHEMA RATHER THAN
MIGRATIONS? IS IT TO AVOID ANY DATA BEING LOADED BY MIGRATIONS FOR
THE TEST DATABASE?
The main reason, I believe, is for speed. The thinking is that there’s
nothing in the test database that needs to be saved, whereas, you might
have
pseudo-real-world data in your development database that you don’t want
to
repopulate. Therefore, the test db is created from scratch, but the
development (and production) dbs are migrated.
==> Q5. WHY IS IT RUN MULTIPLE TIMES?
Is that what you’re seeing? I assume you’re running ‘rake
db:test:prepare
–trace’?
- rake db:test:purge - Empty the test database
=> Q6. WHY IS IT RUN MULTIPLE TIMES?
=> Q7. DOES IT DROP TABLES ALSO?
I haven’t looked into those tasks, myself.
Probably the very best way to answer these questions is to have a look
at
lib/tasks/databases.rake in your Rails framework directory.
///ark