We have a rails app, and I am developing a rails engine (let's call it engine A) to attach to the rails app. Engine A is specified in the gem file of the rails app. Engine A is a wrapper of a public rails engine gem (let's call it engine B), so engine A's gemspec file has a line to add engine B as an dependency. Engine B was not added to the gem file of the rails app in order to keep the main app clean. Therefore, the dependency chain of the rails app, engine A and engine B look like the following:
Rails app >> Engine A >> Engine B
Engine B was installed correctly after running a
bundle install at the rails app.
It is well known that we can run the following command at the rails app to install database migrations of an engine:
rake railties:install:migrations FROM=engine_name
Engine B required a database migration, so I ran the command below at the rails app:
rake railties:install:migrations FROM=engine_B
However, migration files were not generated at
db/migrate directory of the rails app after that. After hours of search and try-and-error, I solved it by adding a line
require 'engine_B' into file
lib/engine_A/engine.rb under engine A's directory. Then, database migration files for engine B can be correctly created by rerunning the command above.
Unfortunately, I also don't know why this solution could work...