[Feature Request] Switch between postgres schemas for multi-tenant use-cases
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 12/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- postgresql, typescript
- 领域
- databases
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 2.9k
- 派生
- 157
- 平均合并
- 2 天 7 小时
- 30 天内合并 PR
- 18
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
zenstackhq/zenstack 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
zenstackhq/zenstack#2873 ·
维护者通常 1 天内回复
-
`@default` on a field of a `@map`-ed enum emits the enum name as the column default可能重新可做 @jkugsiya 于 8 天前认领,目前没有进行中的 PR。 未关闭runtime
难度 2/5 1-3 小时 新手友好度 78/100
zenstackhq/zenstack#2868 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
zenstackhq/zenstack#2694 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
zenstackhq/zenstack#2659 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
zenstackhq/zenstack#2542 · 1 条评论 ·
维护者通常 1 天内回复
查看 zenstackhq/zenstack 的全部 Issue
相似的 Issue
-
frontend
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
ranxianglei/billion-context#4172 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
awslabs/threat-composer#362 ·
维护者通常 1 天内回复
-
Area/Cloud Needs Triage Type/Bug
难度 1/5 1-3 小时 新手友好度 86/100
wso2/product-integrator#2847 ·
维护者通常 1 天内回复