Skip to content

Multiple databases, main DB is assumed even though it's specified in the model. Is there a better way? #399

@epetre

Description

@epetre

One of our models is connecting to a warehouse DB since it's for reporting and not to serve the app features.
That model is based on a materialized view.

When refreshing, we currently can't use Scenic.database to connect to the database because it defaults to the main DB (it seems).
It's not a major issue since we can simply use the connection from the model, but I am wondering if scenic supports this and I am missing something or if it doesn't.

  # In one of my models
  
  def self.refresh
     Scenic.database.refresh_materialized_view(table_name, 
                                               concurrently: false, 
                                               cascade: false)
  end

Instead we have to do this workaround which works fine, but I wonder if there is a better way?

def self.refresh
  connection.execute("REFRESH MATERIALIZED VIEW #{table_name};")
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions