Forum: Rails Engines development using a generator to handle migrations

Bfccdb1c41c334fec20e5ede3a7ccfcc?d=identicon&s=25 Andrew Roth (andrewroth)
on 2009-09-07 16:05
(Received via mailing list)
James, on your presentation at railsconf (
http://rails-engines.org/news/2009/05/18/engines-a...) you
suggest
(for now) making your own generator to handle the migrations issue.  Can
you
elaborate on that method?
Cdeb3717947dec41ae5dc2e777ec0840?d=identicon&s=25 Cynthia Kiser (Guest)
on 2009-09-07 23:03
(Received via mailing list)
Quoting Andrew Roth <andrewroth@gmail.com>:
> James, on your presentation at railsconf (
> http://rails-engines.org/news/2009/05/18/engines-a...) you suggest
> (for now) making your own generator to handle the migrations issue.  Can you
> elaborate on that method?

I am not James - but I recently needed something like that. I used the
Clearance engine as a model for buillding the migrations I wanted.

http://github.com/thoughtbot/clearance/tree/master

James, is there video anywhere of your talk? I got a lot out of the
slides but there are a couple where I would like more detail as was
probably provided at the talk.
--
Cynthia Kiser
20597d3cdf007a1c9bb0da959ebb8257?d=identicon&s=25 Miles Georgi (Guest)
on 2009-09-07 23:06
(Received via mailing list)
Not sure if it's useful information or not, but in the repository I
use for engines, I've made it simply use the current Rails migration
mechanism, ie, no generator is required, the migrations in plugins are
automatically ran.

My repository is way out of date though... I should really do a pull
to see if it works just fine with the recent changes.

Miles
7aef4541a1355c993c66237b162d9681?d=identicon&s=25 Henry GP (henryp)
on 2009-09-07 23:10
(Received via mailing list)
I've got a small plugin that might help you:
http://github.com/hpoydar/engines-helper
Acd62030df551952268e84c8fff26a5b?d=identicon&s=25 James Adam (lazyatom)
on 2009-09-07 23:13
(Received via mailing list)
2009/9/7 Cynthia Kiser <cnk@caltech.edu>:
> Quoting Andrew Roth <andrewroth@gmail.com>:
>> James, on your presentation at railsconf (
>> http://rails-engines.org/news/2009/05/18/engines-a...) you suggest
>> (for now) making your own generator to handle the migrations issue.  Can you
>> elaborate on that method?
>
> I am not James - but I recently needed something like that. I used the
> Clearance engine as a model for buillding the migrations I wanted.
>
> http://github.com/thoughtbot/clearance/tree/master

This is basically correct - you want to use the 'migration_template'
method available in the generator mechanism to copy a migration file
into db/migrate, and Clearance is a reasonable example where this
happens.

The reason we do this is to place the migration in the appropriate
part of the application timeline; this is one of the issues I covered
in my presentation. You can see my blog for more discussion of this
(http://interblah.net/plugin-migrations), but the gist is that I
believe it is important to preserve the order migrations were applied.

The other part of the migration issue is tracking which migrations
have already run; there's no reason why you couldn't run the migration
generators from Clearance multiple times, for example. This isn't a
big deal normally, but comes into play if you're trying to 'upgrade'
an engine in-place, and incorporate a new migration.

> James, is there video anywhere of your talk? I got a lot out of the
> slides but there are a couple where I would like more detail as was
> probably provided at the talk.

There's no video (probably for the best, to be honest), but I'm happy
to answer questions here, if you've got them.

- James
This topic is locked and can not be replied to.