# Re: Question about how engine plugin handlesmigrations

**URL:** <https://www.ruby-forum.com/t/re-question-about-how-engine-plugin-handlesmigrations/119402>\
**Category:** Engines\
**Created:** [November 6, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/re-question-about-how-engine-plugin-handlesmigrations/119402 "2007-11-06T19:21:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trevor\_Rowe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@Trevor\_Rowe](https://www.ruby-forum.com/u/Trevor_Rowe)\
**Post date:** [November 6, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/re-question-about-how-engine-plugin-handlesmigrations/119402/1 "2007-11-06T19:21:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trevor\_Rowe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@Trevor\_Rowe](https://www.ruby-forum.com/u/Trevor_Rowe)\
**Post date:** [November 6, 2007, 8:38pm UTC](https://www.ruby-forum.com/t/re-question-about-how-engine-plugin-handlesmigrations/119402/2 "2007-11-06T20:38:02Z")

</div>

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
