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

How can I set the schema? #457

Closed
jashworth opened this issue Feb 20, 2023 · 3 comments
Closed

How can I set the schema? #457

jashworth opened this issue Feb 20, 2023 · 3 comments
Labels

Comments

@jashworth
Copy link

Is there a way to set the schema so that I don't have to prefix table names with it in every query?

I've tried including it in the call to createPool as a parameter to the connection url:
postgres://...?schema=myschema
postgres://...?currentSchema=myschema
but that doesn't seem to work.

thanks

@gajus gajus added the question label Feb 23, 2023
@gajus
Copy link
Owner

gajus commented Feb 23, 2023

Does https://www.npmjs.com/package/pg support this?

@jashworth
Copy link
Author

I got it working by setting the PG_OPTIONS environment variable.

PG_OPTIONS="-c search_path=my_schema"

thanks

@mull
Copy link
Contributor

mull commented Apr 13, 2023

If anyone else arrives here scratching their head for a while, the trick is that it's PGOPTIONS, not PG_OPTIONS :)

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

No branches or pull requests

3 participants