Forum: Rails Engines The state of Rails 2.3 / Engines migrations

Efe398b3b5436b0a8d4430090e8f86ea?d=identicon&s=25 seth b. (subimage)
on 2010-02-09 22:43
(Received via mailing list)
Hey everyone,

I've been out of the loop for a minute regarding engines, but I'm
looking to update Substruct to Engines 2.3/Rails 2.3 if possible.

My last investigation stopped when running into the migrations issue.
I'm wondering if there is a recommended way to handle engine
migrations / legacy migrations (001_my_migration.rb) with 2.3. The
official site mentions some "things being in the works" but I didn't
really see anything past that.

Any advice or a link to a blog post would be cool. Thanks much.
206b01d5765d45a6db9f3fbd1173fd18?d=identicon&s=25 Nat Budin (Guest)
on 2010-02-09 22:47
(Received via mailing list)
I've been handling them by including a generator in my plugin, which
generates a migration (or possibly multiple migrations).  You'd have to
generate and run the migration in each app using the plugin, which is a
bit
clunky, but seems to be okay as a workaround.

Nat
E862fb7db4f79f9f6a241c37094e290d?d=identicon&s=25 Rob Morris (Guest)
on 2010-02-09 22:54
(Received via mailing list)
Having just taken the plunge and updated my old 2.0.2 site to 2.3.5 with
all the trimmings, I can offer a few thoughts.

The latest engines plugin does handle legacy migrations, but you need to
do some tweaking.

First off, you need to set Rails to use numeric migrations, or you'll
have lots of headaches.  Alternately, I suppose you can manually
timestamp your old migrations, but I haven't tried that one yet...  You
can set Rails to use numeric migrations by setting:
config.active_record.timestamped_migrations = false

Once that's done, you need (possibly) to run: rake
db:migrate:upgrade_plugin_migration

This will make sure you have the proper DB tables, and put an entry into
that table for every old plugin migrations you have, in the format
"<#>-<plugin-name>"

At this point, you should be in good shape.  Your db state matches your
code state, with one entry in schema_migrations for every plugin
migration and every main app migration.

The final trick is to use: rake db:migrate:all

Use this to upgrade your DB instead of the old ./script/generate
plugin_migration bit.  The engines plugin will run all existing plugins,
find all new migrations, and apply them correctly.

Hope that helps!

-Rob
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2010-02-11 16:55
(Received via mailing list)
only thing I know of is
http://www.ruby-forum.com/topic/196976#new

I think I got migrations to work all right.  It's been awhile.

-r
Efe398b3b5436b0a8d4430090e8f86ea?d=identicon&s=25 seth b. (subimage)
on 2010-08-27 03:26
Rob Morris wrote:
> Having just taken the plunge and updated my old 2.0.2 site to 2.3.5 with
> all the trimmings, I can offer a few thoughts.
>
> The latest engines plugin does handle legacy migrations, but you need to
> do some tweaking.
>
> First off, you need to set Rails to use numeric migrations, or you'll
> have lots of headaches.  Alternately, I suppose you can manually
> timestamp your old migrations, but I haven't tried that one yet...  You
> can set Rails to use numeric migrations by setting:
> config.active_record.timestamped_migrations = false
>
> Once that's done, you need (possibly) to run: rake
> db:migrate:upgrade_plugin_migration
>
> This will make sure you have the proper DB tables, and put an entry into
> that table for every old plugin migrations you have, in the format
> "<#>-<plugin-name>"
>
> At this point, you should be in good shape.  Your db state matches your
> code state, with one entry in schema_migrations for every plugin
> migration and every main app migration.
>
> The final trick is to use: rake db:migrate:all
>
> Use this to upgrade your DB instead of the old ./script/generate
> plugin_migration bit.  The engines plugin will run all existing plugins,
> find all new migrations, and apply them correctly.
>
> Hope that helps!
>
> -Rob

That does help and I think I'll go with that.

I've found you can run rake db:migrate:plugin NAME=pluginname and it
runs fine.

The only issue I can't seem to solve is how to back out migrations
applied in this way. Have you any guidance there?

Doesn't look like there's any sort of rake db:migrate:plugin:down
...wondering if there should be?
This topic is locked and can not be replied to.