/scenic-multiple-database

Explores issues with Scenic working with multiple database types

Primary LanguageRuby

Scenic - Multiple Database

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 and legacy in database.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's migrations_paths folder, and rake 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 the schema.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 the scenic-mysql_adapter to the app, and also includes the additional migrations from the pg-pg branch. The fix in the initializer makes Scenic switch between the two adapters as necessary to make rake db:migrate work.