Migrate Test DB plugin

Plugin details

MigrateTestDB plugin was created to allow migrations to be used to generate the test database in rake test commands. This is helpful for consistently testing migrations, but was absolutely for the following use case we encountered:

Using VIEWS or STORED PROCEDURES. We were using a legacy database (a legacy MS SQL server for production, MySQL 5 for development and tests). Neither schema format (:ruby or :sql) plays nicely when exporting the schema for the database. They do not output the VIEWS nor STORED PROCEDURES so all of our tests requiring this functionality failed.

MigrateTestDB deletes Rails' default test:db:prepare task which only supports schema_format = :sql and schema_format = :ruby. The replacement task works identically (as of Rails 1.2.3) to Rails default task; however, specifying a schema_format = :migrate will cause a new preparation task to run within the plugin. The task runs migration scripts to ready the test database. The plugin leverages the existing rake tasks for purging the test database, and loading the migration scripts--so the plugin code is mainly a reglue of exisiting Rails default functionality.

Websitehttp://www.elctech.com/2007/7/12/migrate_test_db Repositoryhttp://svn.elctech.com/svn/public/plugins/migrate_test_db Author Jonathan Siegel Tags Tests LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.elctech.com/svn/public/plugins/migrate_test_db

Edit config/environment.rb:

config.active_record.schema_format = :migrate



That's it! The next time you run rake (or any rake task that depends on the test:db:prepare task) you'll see that your test database is being generated from your migrations.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: Guest, 8 months ago