We have a Rails engine (developed in-house) that's bundled into our main Rails app. To reduce the load on our current database server; we want to use the multiple databases feature in Rails 6. I've defined a second database in config/database.yml:
development
primary:
<<: *default
database: primary-dev
engine:
<<: *default
database: engine-dev
migrations_paths: <what should this be set to?>
and the Rails app recognises that another database has been defined. However, what do I set migrations_paths to, so that the second database uses the migrations defined in the engine?
I've tried bundle exec rails engine:install:migrations to move the migrations into the Rails app, manually moved them to a sub-directory and set migrations_paths to that. However, this seems quite clunky and wondered if there was a different syntax to reference the migrations in the engine?
Should the engine have its own config/database.yml that defines its database? How do I pass the database connection details down from the Rails app to the engine? Is that just part of the initialisation of the engine?
You can find the migration path with the following command :
for an engine named 'MyEngine'.
You do not need to copy migrations if you add the migrations_paths to your database configuration.