rivet-gg / rivet

🔩 The only backend your multiplayer game needs. Open-source & self-hostable.
https://rivet.gg
Apache License 2.0
2.03k stars 47 forks source link

Handle multiple schemas with single Prisma client #929

Closed NathanFlurry closed 3 days ago

NathanFlurry commented 3 months ago

Motivation

We currently need a separate Prisma client for each database schema. This requires a separate pool, which means more Postgres connections than needed.

Implementation

This is currently not yet possible.

Prisma now support multiple schemas, but the tables are in the same namespace: https://www.prisma.io/docs/orm/prisma-schema/data-model/multi-schema

The only way to hack around this would be to write a script to rename the models (and us @@map to keep the name consistent) then use a proxy to provide the correct table.

Misc

It looks like Prisma investigated separating tables by schema, but since deleted the GitHub comment: https://arc.net/l/quote/kuaashkx

linear[bot] commented 3 months ago

RVT-3797 Handle multiple schemas with single Prisma client