Has anyone thought about having a fourth database, maybe called
template. e.g. foo_template, foo_development, foo_test, and
The rake db:migrate would be done to the template database. Then the
test and development would be initially populated from the template.
I am not sure if all databases have this ability. I'm using
postgresql. I can do:
createdb --template=foo_template foo_test
There are a couple of reasons.
First, if I add a procedural language to my development database, then
I can not create the test db without some sort of error unless I use
postgres as the user of the test database. I'd prefer not to do
that. Either using ruby or sql as the schema_format has
difficulties. Using ruby, the constraints are not saved; using sql, I
get a couple of ugly warnings.
The second reason is my migrations add required data to the database.
Neither method of db:test:clone or db:test:clone_structure migrates
these entries. Using fixtures solves this but then I need this same
fixture for all of my tests.
It also appears to be faster and dumping things to a file and sucking
them back up.