This repository contains a basic Rails 6 app that combines multiple database configurations with the Scenic gem.
The repository includes branch heads at the following points:
-
pg-pg: On this branch the app is configured with two Postgres database connections,
primary
andlegacy
indatabase.yml
. It also includes migrations that add tables and views to both of these databases. The current version of Scenic works correctly in this scenario. The migrations are in each connection'smigrations_paths
folder, andrake db:migrate
correctly creates the views in the appropriate databases. -
pg-mysql: On this branch the
legacy
database has been switched to MySQL. This causes Scenic to fail when theschema.rb
file for the legacy database is being generated, even when it contains no views. I've filed a GitHub issue for this. -
pg-mysql-fix: This branch adds an initializer that fixes the issue by choosing the correct Scenic adapter to match the database connection that is in use.
-
master: The
master
branch pulls these threads together: it uses the initializer to add thescenic-mysql_adapter
to the app, and also includes the additional migrations from thepg-pg
branch. The fix in the initializer makes Scenic switch between the two adapters as necessary to makerake db:migrate
work.