Pull from an existing schema, but skip in migrations?
Hey all, I'm trying to do something a bit weird. I have a Keycloak instance that I am using to manage user identity, and have the schema stored in my postgres database in the "keycloak" schema. I would love to be able to reference user_entity ids in my public schema (managed by drizzle). I was able to (mostly) pull the keycloak schema using drizzle kit pull, but then, when I try to create migrations, it attempts to create all of the existing keycloak schema (which itself is managed by another migration tool).
Is there a way to pull in an existing schema, but to skip it when it comes to migrations?
Essentially, I just want to be able to build relations, and ideally create row-level security policies. thanks!
Is there a way to pull in an existing schema, but to skip it when it comes to migrations?
Essentially, I just want to be able to build relations, and ideally create row-level security policies. thanks!
1 Reply
đź‘‹
The easiest way is to manually create a “keycloak” schema, then a table linked to this schema and just add columns you want to use.
Do not export them from your schema.ts so they will not be part of any migration.
This is how I did for Supabase (before it was built in to Drizzle): https://github.com/rphlmr/drizzle-lab/blob/main/apps/drizzle-run/app/database/.server/schema.ts#L18-L22
GitHub
drizzle-lab/apps/drizzle-run/app/database/.server/schema.ts at main...
Play with Drizzle everywhere. Contribute to rphlmr/drizzle-lab development by creating an account on GitHub.