Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Rails' multiple database feature #402

Open
3 tasks
derekprior opened this issue Jan 20, 2024 · 2 comments
Open
3 tasks

Support Rails' multiple database feature #402

derekprior opened this issue Jan 20, 2024 · 2 comments
Milestone

Comments

@derekprior
Copy link
Contributor

derekprior commented Jan 20, 2024

For some time now, Rails has offered multiple database support. Scenic, however, operated with the assumption that there is one database, hanging its functionality off the singleton, Scenic.database. We should make the changes necessary to support multiple databases, which may have the added benefit of easily offering view path configurability as has been asked for by a number of folks.

I'm currently messing with multiple databases in a sample app and will use this issue to enumerate the changes I think we need to make.

  • Teach our generators about the --database option
  • Use context available within a migration to execute DDL in the correct database
  • Update methods accessed from models at runtime to respect the database used in the model
@leoplct
Copy link

leoplct commented Feb 29, 2024

In the meanwhile, what workaround could I use to run Scenic on my secondary database?

@joshfester
Copy link

joshfester commented Sep 19, 2024

@leoplct I use Scenic in my primary database, but not in my cache database (SQLite). I was able to get rails db tasks to work by creating an initializer with this:

# Don't use Scenic in db tasks for SQLite
module CustomSchemaDumper
  def dumpable_views_in_database
    if ActiveRecord::Base.connection.adapter_name == "SQLite"
      []
    else
      super
    end
  end
end

# Don't use Scenic in db tasks for SQLite
module Scenic
  module SchemaDumper
    prepend CustomSchemaDumper
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants