Hi there,
I have a setup of PostgreSQL database with multiple schemas. They have some tables with the same name.
Is there any possibility use multiple gateways for different search_paths?
Hi there,
I have a setup of PostgreSQL database with multiple schemas. They have some tables with the same name.
Is there any possibility use multiple gateways for different search_paths?
Welcome @krautcat! Yes, you can do this. If you show me how you’re defining your gateways presently I can give you more personalized advice, but in general it would look like this:
ROM.container(
default: [:sql, database_url, search_path: 'public'],
legacy: [:sql, database_url, search_path: 'alternate']
) do |config|
# setup code goes here...
end
alternately, you can define gateways separately first
default = ROM::Gateway.setup(:sql, database_url, search_path: 'public')
alternate = ROM::Gateway.setup(:sql, database_url, search_path: ['alternate', 'public'])
ROM::Configuration.new(default:, alternate:) do |config|
# setup code goes here...
end
search_path
in this example is a Connection Option for the Sequel driver. This means you could also embed it as a query param into the DATABASE_URL, but I think doing it in Ruby is more clean.
Sorry for late reply.
Thank you, I’ve done it, and everything works!