How to manage migration for rails engine + dummy application

I just joined a project developing the rails engine, which also has a dummy application for testing.

foo/ foo/spec/dummy/ 

There are identical migrations in

 foo/db/migrate/ foo/spec/dummy/db/migrate/ 

If I rake db:migrate from a dummy application, all is well. If I do the same with the engine (current directory = foo), I get an error message with multiple migrations with the same name.

Q1) Are rakefills? (should db:migrate return to the dummy application?)

Q2) Should migrations be in only one directory? If so, which one?

We are using Rails 3.2.9, ruby ​​1.9.3p194.

+6
source share
1 answer

Question 1
There should be an entry in the Rakefile for the spec / dummy account. For instance,

 Bundler::GemHelper.install_tasks APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__) load 'rails/tasks/engine.rake' 

Here's a more detailed rakefile example, https://github.com/twinge/questionnaire_engine/blob/engine2/Rakefile

Question 2
IMO, migrations should exist only in the foo / db / migrate folder, and not - foo / spec / dummy / db / migrate. In fact, I do not control the version of dummy db / migrate or db / schema.

Why? I use a dummy application to make sure that the full installation of my engine works 100%. Therefore, if I controlled the state of foo / spec / dummy db, I would test as if there was a previous installation.

Engine example
https://github.com/twinge/questionnaire_engine/tree/engine2

+7
source

All Articles