drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
21.47k stars 486 forks source link

[BUG]: pushing to db fails as it automatically adds drop primary key #2458

Open IzaanAnwar opened 3 weeks ago

IzaanAnwar commented 3 weeks ago

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.4

Describe the Bug

This is the table that is suggested by next-auth when using drizzle.

Screenshot_20240605_144052

When I am pushing any db changes (I am not even modifying the account table), it throws an error which is as follows:

code: undefined, errno: 3750, sql: 'ALTER TABLEaccountDROP PRIMARY KEY;', sqlState: 'HY000', sqlMessage: "Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting."

Expected behavior

When I first started the project, everything was running smoothly. However, I'm not sure what's happening now.

Environment & setup

MySQL 8.0.30 on AIVEN

dearzubi commented 2 weeks ago

Hi, I am running into a similar situation. Push starts to drop the authentictor table's "authenticator_userId_credentialID_pk" constraint and exits with the error that this constraint does not exist. However, it does exist but the point is why delete and recreate it while I am not doing anything with that table?

IzaanAnwar commented 2 weeks ago

@dearzubi I was using aiven/mysql for the database, I switched to docker as it was very tidious to delete and start again, it fixed the problem but later I will need to use aiven hoping someone would fox it or explain the problem

dearzubi commented 2 weeks ago

@dearzubi I was using aiven/mysql for the database, I switched to docker as it was very tidious to delete and start again, it fixed the problem but later I will need to use aiven hoping someone would fox it or explain the problem

I am using PostgreSQL in docker. Hopefully, somebody fix it.