I recently started using migrations to create the schema of a Rails
project I am working on. The database I am using for this project is
MySQL. The initial migration creates the table and also includes a
number of execute statements (to do some things like setting primary
keys, autoincrement on some columns and other messy voodoo).
Running “rake migrate” creates the database with no problems and
everything is happy in my world!
However things go wrong when I run “rake test_units”. Basically the test
database is not recreated properly. I delved into the testing.rake and
databases.rake files to see what is going on, and this is my
- “rake test_units” recreates the test database by running the
- However this file will NOT include any “execute” actions, thus
resulting in a different database structure in development and test
In my case the above behaviour causes some of my unit tests to fail. But
if I explicitly do a “rake clone_structure_to_test” and then explicitly
run individual unit tests, the tests all pass with flying colours.
I think the test database also needs to be generated by applying all the
migration steps, and that the current behaviour is buggy. Of course
there might be a really good reason for the behaviour which I am not
getting at all. Thoughts, comments, suggestions?