drizzle-kit generate:pg - generates incorrect reference to table in another schema?
As im not super comfortable in pgsql, so im unsure if this is intended, or if its a bug with drizzle-kit.
Im trying to create a fk reference to "auth"."users", inside my "public"."profiles" table.
But drizzle-kit seems to not generate the script with correct reference to the database schema -, am i missing something?
Here is the .ts file:
And here is the generated script by drizzle kit:
5 Replies
This is a known bug on the drizzle-kit side: https://orm.drizzle.team/kit-docs/faq#using-multiple-schemas-in-postgresql
FAQ & Troubleshooting - DrizzleORM
Drizzle ORM | %s
I looked at that one as well, but tought that this part:
Meant that all would be "ok ish" as long as i dont name tables the same.
I guess this is not true when referencing tables in other schemas then? Postgres throws up when trying to migrate that file, cause i guess its looking for the users table, in its default search_path?
I guess that line assumed you wouldn't be referencing tables from one schema on another schema.
One workaround would be to just edit the migration derectly before applying it
Pinging @a_sherman for visibility
Yeah, thats what i will do for now. And with some automated checks/rules in my migrate.ts file, i guess its to overcome!
Appreciate your guidance very much 🙂
yes, need to update docs about that, reference across schemas is also a bug, that we are aware of
but I guess we will prioritize open-sourcing drizzle-kit and then we will work on fixing those issues