Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
MigrateTestDB by Jonathan Siegel (firstname.lastname@example.org) ELC Technologies (http://elctech.com/) =============== 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. This code was originally developed as a patch for railsties/lib/rake/databases.rake. The patch was developed by Andre Price under the direction of Jonathan Siegel at ELC Technologies. It was submitted for inclusion to Rails core and received the response: http://dev.rubyonrails.org/ticket/4814#comment:1> "This is a great idea for a plugin. If you release it and most Rails developers begin using it then it might be a good candidate for core. Until then I'm going to close this ticket." The patch was converted to a plugin by Jonathan Siegel. Usage ===== 1. Install the plugin: ./script/install plugin http://svn.elctech.com/svn/public/plugins/migrate_test_db or with external SVN reference: ./script/install plugin -x http://svn.elctech.com/svn/public/plugins/migrate_test_db 2. Edit config/environment.rb: config.active_record.schema_format = :migrate 3. 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.