Question :
I have a project in heroku. I have the URI that enables me to connect with the database in my external rails app. How do I change or set the search path in ruby code?
Answer :
You can define it in your database.yml using the schema_search_path key with a string value
production:
adapter: postgresql
...
schema_search_path: 'schema1,public'
You can find out a bit more here: https://til.hashrocket.com/posts/5aa2892b43-set-schema-search-path
For the session, when inside/connected with psql, you can use SET
search_path =
. Or you can use the GUC and change the default for the user or database which will impact all connections from the user or to the specified database.
ALTER ROLE myUsername SET search_path = ...
ALTER DATABASE myDatabase SET search_path = ...