Installing migrations from engine won't work
Asked Answered
B

3

7

I created a new engine in Rails 3.1.3 and apparently there's that rake task that copies over all migrations. I tried following rake abc:install:migrations which threw:

rake aborted!
Don't know how to build task 'abc:install:migrations'

(See full trace by running task with --trace)

I also tried rake abc_engine:install:migrations with the same result.

Then I read bundle exec rake railties:install:migrations or bundle exec rake railties:install:migrations FROM=abc_engine should do the trick too but no success. Nothing was copied even though no error was thrown.

My migrations are located in db/migrate/ within the engine folder and I ran all commands above from spec/dummy/

Does anyone know how to use this new rake task in order to copy migrations from the engine?

Beast answered 5/1, 2012 at 15:35 Comment(1)
I'm stuck like you, the documentation is really lacking here!Juli
D
10

I ran this instead:

rake railties:install:migrations

And my migrations were copied from the engine. Hope this helps.

Demerit answered 18/7, 2013 at 19:55 Comment(0)
J
2

I finally got found/got lucky with my (similar) issue. For the first error, it just disappeared, not sure why. Then I figured out that I didn't created the migrations using the usual file name format, so the ActiveRecord::Migrator.migrations method was ignoring them.

Juli answered 19/3, 2012 at 22:16 Comment(1)
Thanks for pointing out that migraitons are part of activerecord, I don't have it in my project so that was not working :/Taphouse
M
2

If the app you're mounting the engine to doesn't already have ActiveRecord (i.e. you're introducing ActiveRecord to your host app for the first time by mounting the engine), you can get this error as well. Specifically, you'll get this error if you don't have require "active_record/railtie" in your application.rb, or if it's commented out. That line is what enables the rake railties:install:migrations task, which is defined here. rake railties:install:migrations is, in turn, called by the rake abc_engine:install:migrations task here.

Tl;dr: try adding require "active_record/railtie" to your application.rb if it's not already there.

Miculek answered 13/11, 2017 at 22:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.