drizzle-kit push tries to re-define all primary keys when updating schema (mysql/mariadb)
When I run drizzle kit push it tries to redefine all primary keys which of course ends up in a failure. I am using MariaDB with the mysql driver, so I've had to make a few adjustments to make it work (like not using serial).
Schema: https://pastebin.com/WxPcMCX0
Pastebin
schema.ts - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
8 Replies
You had an already existing db with populated tables then started using Drizzle?
Other way around
No populated tables
@TOSL seems I identified a separate issue, will rename this thread and update it to actually describe the issue
I did not have an existing db, or I had an empty database to let drizzle populate it. First run always works, but if I try to update any tables with new fields it fails with the error above. Here's a github issue describing the same problem: https://github.com/drizzle-team/drizzle-orm/issues/3473
GitHub
BUG
drizzle-kit push:mysql
with Two Primary Keys · Issue #3473 · ...When you have a schema that contains two Primary Keys drizzle-kit is able to push the initial database creation but fails on future runs. When checking the verbose logs you can see drizzle-kit is a...
okay this seems like a mariadb-specific issue
Did you run drizzle generate at any point?
Yes I did. Found a workaround. I can’t run push, instead I must first generate then migrate, push seems to be the command that simply fucks up
I could be wrong but suspect the bug is some type of conflict from having both. If you'd like to use push, I suggest you delete your migration files and stick to just push.
Yeah
Tbh I couldn’t get querys to work with MariaDB so I switched over to MySQL (even though I prefer MariaDB). Everything works smoothly now, but when the MariaDB driver comes out I’ll switch back