SpamixTheProducer
SpamixTheProducer
DTDrizzle Team
Created by SpamixTheProducer on 12/31/2024 in #help
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).
❯ bun drizzle-kit push
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/drizzle.config.ts'
[✓] Pulling schema from database...
Reading schema files:
/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/src/drizzle/db/schema.ts

Error: Multiple primary key defined
at PromiseConnection.execute (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/mysql2/lib/promise/connection.js:47:22)
at Object.query (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:79025:40)
at mysqlPush (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:82057:22)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.handler (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:92160:9)
at async run (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:90501:7) {
code: 'ER_MULTIPLE_PRI_KEY',
errno: 1068,
sql: 'ALTER TABLE `challengeFiles` ADD PRIMARY KEY(`id`);',
sqlState: '42000',
sqlMessage: 'Multiple primary key defined'
}
❯ bun drizzle-kit push
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/drizzle.config.ts'
[✓] Pulling schema from database...
Reading schema files:
/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/src/drizzle/db/schema.ts

Error: Multiple primary key defined
at PromiseConnection.execute (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/mysql2/lib/promise/connection.js:47:22)
at Object.query (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:79025:40)
at mysqlPush (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:82057:22)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.handler (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:92160:9)
at async run (/home/alexander/Documents/git/spamixofficial/decompil.in-web/backend/node_modules/drizzle-kit/bin.cjs:90501:7) {
code: 'ER_MULTIPLE_PRI_KEY',
errno: 1068,
sql: 'ALTER TABLE `challengeFiles` ADD PRIMARY KEY(`id`);',
sqlState: '42000',
sqlMessage: 'Multiple primary key defined'
}
Schema: https://pastebin.com/WxPcMCX0
12 replies