[BUG] Multi schema tables with same name

I have two tables with the same name in two different schemas. Drizzle seem to not take into account the schema when generating the SQL, and it generates only one of the two tables. This heavily brakes a lot of functionality
8 Replies
Angelelz
Angelelz16mo ago
You might have done this, but are you creating/defining your tables as described here? https://orm.drizzle.team/docs/schemas
Boian Ivanov
Boian IvanovOP16mo ago
Yes, this is exactly the way we’ve done this. Even if table A is in the public schema (no schema) and table B is in a schema, as long as they have the same exact name, drizzle is confused, so it looks like it’s not taking into account the schema choice when generating the migrations and the last table is overwriting the first one. The only way around this is for the names to not conflict, which might not be ideal depending on use case I’ve even tried having the non schema tables in a root schema hoping that there won’t be a conflict, but as the schemas are not taken into account, the migrations are still using the one table that’s defined last in the schema
Angelelz
Angelelz16mo ago
Unfortunately, it's a known bug on the drizzle kit side https://orm.drizzle.team/kit-docs/faq#using-multiple-schemas-in-postgresql
Angelelz
Angelelz16mo ago
Other than the workaround offered there, you could edit your migrations manually, unfortunately. Pinging @a_sherman for visibility
Boian Ivanov
Boian IvanovOP16mo ago
Yes, we've tried working around it, but it's quite hard, especially when the design of the database requires same names. Are there any potential ideas on where the bug may be, as I might be able to try and fix it As I've been on the lookout of how this can be fixed, I've stumbled upon the fact that this is caused by the "drizzle-kit" package which is not OSS, which makes it even harder when trying to figure out how this issue can be resolved. From what I can see initially from the transpiled .cjs file it seems that the schema passthrough on generation at some point doesn't reach the full extend of the it reference, but it's quite hard to understand when the source is not publicly available :/
Angelelz
Angelelz16mo ago
My understanding is that the kit will be open source soon. I myself am waiting for this as it's lacking functionality for me as well. In particular, fullText index and correct defaults for datatime types
Boian Ivanov
Boian IvanovOP16mo ago
Let's hope you're right and they do open source it soon enough 🤞 Thank you for the info though 👌
Andrii Sherman
Andrii Sherman16mo ago
Yes, we've decided to make open-sourcing a priority and then will work on other issue fixes because previous strategy didn't work where we thought we can fix issues and then open source it so will change it now sorry for that, and thanks a lot for your patience
Want results from more Discord servers?
Add your server