Forum: Rails Engines Re: Question about how engine plugin handlesmigrations...

Posted by Trevor Rowe (Guest)
on 2007-11-06 19:21
(Received via mailing list)
Plugin Migrations have their own version history.  Their version numbers
are kept in a table called 'plugin_schema_info', which has 1 row per
plugin with migrations.

The script/generate plugin_migration generates client migrations that
place themselves sequentially at the end of the client migrations.  So
in your example, the newly added core_wiki migration would get copied
into the client my_custom_wiki but would be numbered as client migration
007.

The script/generate plugin_migration uses the plugin_schema_info version
number associated with core_wiki to see how far your client has already
been migrated and then copies the un-executed migrations to the client.

Actually it doesn't copy them, it puts a placeholder migration that just
calls the migration on the plugin class, like:

class CoreWikiToVersion7 < ActiveRecord::Migration
  def self.up
    Rails.plugins["core_wiki"].migrate(7)
  end
  def self.down
    Rails.plugins["core_wiki"].migrate(6)
  end
end

However, I do believe that if you have copied migrations (such as this)
to the client previously, but not executed them yet, and run
script/generate plugin_migrations again you will get extra copies.  I
haven't verified this though.

Trevor Rowe
Posted by Daniel Wintschel (Guest)
on 2007-11-06 20:38
(Received via mailing list)
Trevor,

Thanks a lot - helpful info there. I through together a
proof-of-concept to verify and it's all working as I'd expect. I'm
pleasantly surprised.

Thanks again.
-daniel
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.