-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
What version of drizzle-orm are you using?
0.23.2
Describe the Bug
This is not might be re-labeled as and design/architecture flaw and let me know if I get it wrong but: Imagine the typical multi-tenant app having a separate schema for each customer account - in this case drizzleorm is practically impossible to use since the whole API design revolves around directly including the schema TS code that is static by definition.
I would imagine something like this:
// schema definition
const accountSchema = pgDynamicSchema('account'); // instead of pgSchema, where the string param is just an optional prefix
export const users = accountSchema.table("users", {
//...
}
// some rest endpoint
const currentUserSchema = 'customer_schema_name'
db.select().from(users(currentUserSchema)) // this would then access "account_customer_schema_name" schemaBut I understand this might mean to rewrite the whole thing..
ellis, moritzmla, jean343, kennyjwilli, matheus-silva-fator3 and 17 morereisblucas, JeongJuhyeon and MIKEGUIJARRO