[Feature Request] Switch between postgres schemas for multi-tenant use-cases
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 12/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- postgresql, typescript
- Ambito
- databases
Direzione di ricerca
Read the Kysely schemas recipe linked in the issue and then trace how ZenStack builds its Kysely query-builder calls and its Prisma client wrapper, since a schema switch has to affect both. The thread is an open design discussion with no agreed API, so the first step is a written proposal covering how the schema/search path is set per request and how a single query can override it for cross-schema joins. Done means a reviewable design plus the touched entry points, not a patch.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is your feature request related to a problem? Please describe.
For multi-tenant applications, where there is one tenant per postgres schema, a common requirement is switching the schema based on the tenant. See kysley docs here
Describe the solution you'd like
An api to switch schemas so that in both the query builder api and also the prisma api the sql ends up qualified with the proper schema name/search path. For cross-schema queries, overriding this should work too as mentioned in kysely docs. This means that the db client instance and thereby the connection pool would be shared across all schemas, which is efficient.
A strategy might be that when switching to a schema, it affects prisma query api calls and the kysely query builder calls, but only in kysely can the schema be changed within a single query to do cross schema joins. To enable this in prisma api, an optional schema argument would need to be added somehow.
Describe alternatives you've considered
Create one postgres client per tenant and cache them in memory, disposing them when they go out of use. Each request gets a client along with its db connection pool depending on the tenant id. For low amount of tenants this is ok, but high usage will have a large number of open conn pools which may not be ideal.
I am open to thoughts, ideas on this topic and how best to support it here and in general.
- Lingua principale
- TypeScript
- Stelle
- 2.9k
- Fork
- 157
- Merge medio
- 11h 42m
- PR unite (30g)
- 20
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di zenstackhq/zenstack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
zenstackhq/zenstack#2873 ·
I maintainer di solito rispondono entro 1 giorno
-
runtime
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
zenstackhq/zenstack#2868 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
zenstackhq/zenstack#2694 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
zenstackhq/zenstack#2659 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
zenstackhq/zenstack#2542 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di zenstackhq/zenstack
Issue simili
-
[Bug]: Server git tests sign fixture commits with the developer's key when run from the repo rootAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
melgarafael/DeskcommCRM#2657 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
MystenLabs/MemWal#1163 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Mondriaan
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
knaw-huc/textannoviz#709 ·
I maintainer di solito rispondono entro 1 giorno
-
billion-context-pi
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ranxianglei/billion-context#2521 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno