Multi-tenancy with drizzleAdapter
Hi everyone 👋
I'm working on a multi-tenant application where the database (Postgres) is determined based on the current domain or subdomain. I've customized the migration workflow so I can apply the same migrations across multiple schemas or databases — that part is working fine.
Now I'm facing an issue with the drizzleAdapter used in authentication. The current implementation connects to a fixed schema, but in my case, I need it to connect dynamically based on the current tenant.
Is there a way to pass the tenant context (derived from the domain/subdomain) to the auth handler, or customize the authHandler to inject the appropriate schema/db connection?
Any pointers or examples would be greatly appreciated 🙏
1 Reply
I have done the following for multi tenancy.