This project is archived and is in readonly mode.
Rails3 rake task db:test:prepare no longer handles stored procedures
-
Michael Koziarski
- State changed from new to invalid
- Importance changed from to Low
You need to set config.active_record.schema_format = :sql
That will then use the db-specific schema dumping/loading tools and can load every database specific thing you want to throw at it.
-
James B. Byrne
- Tag cleared.
Forgot about that one. Thanks for the reminder. We just switched over to Rails3 and missed this in the configuration changes.
-
James B. Byrne
Well, it seems that while the advice given is absolutely correct, it is incomplete.
In Rails 3 the default location for the configuration setting config.active_record.schema_format = :sql is config/environments/test.rb. At least that is where the rails project generator template puts it. However, the test.rb configuration file is not used when one runs rake db:test:prepare and RAILS_ENV is set to "development".
It seems to me counter-intuitive that running a rake task in the default (development) environment, without RAILS_ENV set should behave differently than when RAILS_ENV is explicitly set to "development". In fact, it seems odd to me that the test.rb configuration should ever be used outside of an actual test run.
I realize that there is a conceptual crossover here and that preparing for a test is not far removed from performing the test itself. I nonetheless am concerned that mixing the two in this way defeats the purpose of splitting things out into different environment files. If the intent is that running rake db:test:prepare creates the test database differently for each environment that the rake task might be run in then at the very least the default location for this setting should be development.rb and not test.rb. If the intent is that the default treatment is found in test.rb but that this value can be overridden in specific environments then the default should be taken from test.rb first and only overridden if it is also specified in the actual environment configuration file.
The present configuration and usage is somewhat contradictory.