-
Notifications
You must be signed in to change notification settings - Fork 57
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
Handling multiple schemas #50
Comments
@hlascelles, thank you for opening the issue. I'd like to clarify the meaning of "schema" here - do you mean something like a PostgreSQL schema? Or are you saying you're using two |
This is for using with a Postgres DB with multiple (DB) schemas, but one eg:
|
@hlascelles, thanks for clarification. How did you set up Active Record for multiple schemas? |
Almost everything is "normal" (eg the database.yaml), and then for a few models we change the table that ActiveRecord uses to look them up: class NormalModel < ApplicationRecord
# This one is in `public`
end
class OrdersModel < ApplicationRecord
# This one is in `audit`
self.abstract_class = true
class << self
def inherited(subclass)
super
subclass.table_name = "audit.#{subclass.table_name}"
end
end
end That's it. |
So we have a similar setup, except each model exists on two different schemas: Live and Sandbox. |
Bumping this, as I just replaced redis with solid_cable - which will be a default in Rails 8. I followed these steps (had to adjust a bit to make it work) https://github.com/rails/solid_cable?tab=readme-ov-file#installation to setup two databases (one only for actioncable messages). This triggered an error (see below) which I could avoid by adding It would be sufficient for my use case to add an ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "solid_cable_messages" does not exist (ActiveRecord::StatementInvalid)
LINE 10: WHERE a.attrelid = '"solid_cable_messages"'::regclass
[...]
Caused by:
PG::UndefinedTable: ERROR: relation "solid_cable_messages" does not exist (PG::UndefinedTable)
LINE 10: WHERE a.attrelid = '"solid_cable_messages"'::regclass
^
[...]
SolidCable::Message references a non-existent table or view named solid_cable_messages |
Having a similar issue with global :ignore_tables, [ |
We'd like to check multiple schemas in our DB. At present we are using the gem with great success in specs thus:
output = ActiveRecordDoctor::Tasks::UnindexedForeignKeys.new.run
However we can't see an easy way to move between schemas. Is that supported? Thanks!
The text was updated successfully, but these errors were encountered: