Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Specify Postgres schema #2633

Closed
rickb777 opened this issue Aug 18, 2023 · 2 comments
Closed

Specify Postgres schema #2633

rickb777 opened this issue Aug 18, 2023 · 2 comments
Labels
enhancement New feature or request triage New issues that hasn't been reviewed

Comments

@rickb777
Copy link

What do you want to change?

I am interested to use multiple schemas in Postgres. This can for example be used to handle multiple tenants in a single database. Although it's possible to share tables across tenants, it can be better to use more than one schema instead. This isolates each tenant's data from the others. It also reduces the performance costs of each tenant's db load from impacting other tenants because tables hold fewer lines.

Is there a way to use schemas via SQL statements in SQL?

Eg select * from tenant1.user,
where I can replace tenant1 accordingly?

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

@rickb777 rickb777 added enhancement New feature or request triage New issues that hasn't been reviewed labels Aug 18, 2023
@rickb777
Copy link
Author

Additionally, switching schemas would be a useful feature for integration tests that need to be isolated from each other. Creating temporary schemas, using them during a test run, then tearing them down afterwards is a useful technique to allow partitioning such that different tests don't interfere with each other.

@rickb777
Copy link
Author

rickb777 commented Aug 18, 2023

BTW the current workaround is to set up each tenant to have its own default schema in Postgres (i.e. per user role), and then use a separate connection pool with the credentials for each tenant.

This is clumsy and not ideal for the integration test use-casr.

@sqlc-dev sqlc-dev locked and limited conversation to collaborators Aug 18, 2023
@andrewmbenton andrewmbenton converted this issue into discussion #2635 Aug 18, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement New feature or request triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant