Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: Allows rails plugins to manage their own migrations independently of the host rails app
Clone URL: git://github.com/oculardisaster/plugin_migrator.git
Search Repo:
README
Plugin Migrator
-----------------------------------------------------

This plugin is meant to enable other plugins to be able to manage their own migrations. This is done by extending the 
PluginMigrator class and supplying a number of configuration parameters.

Example:

class MyPluginMigrator < PluginMigrator::Migrator

  schema_table_override "my_plugin_schema_info"
  migration_directory "#{my_plugin_root}/db/migrate"
  
end


The #{my_plugin_root} should be a full path preferably based on the location of the file that is extending 
PluginMigrator::Migrator.

So if you have

my_plugin
  db
    migrate
  lib
    my_plugin
      migrator.rb
      
Then you probably would have something that looks like this:

Example:

class MyPluginMigrator < PluginMigrator::Migrator

  schema_table_override "my_plugin_schema_info"
  migration_directory File.join(File.dirname(__FILE__), "/../../db/migrate")
  
end

To invoke your migrator, you simply call:

MyPlugin::Migrator.migrate(ENV['VERSION'],false)

Either from your code or perhaps a rake task like "rake myplugin:migrate"

To run the tests:

% rake spec

I have included example specs and code for the MyPlugin plugin.



Notes: Thanks to the good people at Web Strong Group that allowed me to open source this plugin.