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.57k stars 490 forks source link

[BUG]: Planetscale got packets out of order for 'serial' type on push #2180

Open Flowko opened 2 months ago

Flowko commented 2 months ago

What version of drizzle-orm are you using?

0.30.8

What version of drizzle-kit are you using?

0.20.16

Describe the Bug

trying to push my schema to planetscale i get an error, i have some tables with serial id:

export const posts = mysqlTable('posts', {
  id: serial('id').primaryKey(),
  title: varchar('title', { length: 255 }).notNull(),
  content: text('content').notNull(),
  createdAt: timestamp('created_at').notNull().default(sql`CURRENT_TIMESTAMP`),
  updatedAt: timestamp('updated_at').notNull().default(sql`CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP`),
})

the error i get:

Warning: got packets out of order. Expected 0 but received 2
Error: unknown error: syntax error at position 46 near 'serial'
    at PromiseConnection.execute (C:\Users\folder\node_modules\.pnpm\drizzle-kit@0.20.16\node_modules\drizzle-kit\bin.cjs:59949:26)
    at MySQL2Client.query (C:\Users\folder\node_modules\.pnpm\drizzle-kit@0.20.16\node_modules\drizzle-kit\bin.cjs:62424:35)
    at Command.<anonymous> (C:\Users\folder\node_modules\.pnpm\drizzle-kit@0.20.16\node_modules\drizzle-kit\bin.cjs:66009:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ER_UNKNOWN_ERROR',
  errno: 1105,
  sql: 'ALTER TABLE `posts` MODIFY COLUMN `id` serial AUTO_INCREMENT NOT NULL;',
  sqlState: 'HY000',
  sqlMessage: "unknown error: syntax error at position 46 near 'serial'"
}

mysql version im using:

"mysql2": "^3.9.6"

Expected behavior

it should push this schema fine, as it used to do before, this error only appeared after i updated ot the newer versions.

Environment & setup

No response

Flowko commented 2 months ago

i just downgraded the drizzle-kit version to 0.20.14 and that works fine, so something happneed in the newer versions.

seems to work with these, but not even sure: "mysql2": "3.9.2" "drizzle-kit": "0.20.14"

might be related to mysql driver: https://github.com/sidorares/node-mysql2/issues/653

qw-in commented 2 months ago

Just a note that I'm still seeing this issue on 0.20.17

azezsan commented 2 months ago

+1

pahhh-blo commented 1 month ago

The problem persists on version 0.21.00 with a mysql db on PlanetScale. This extremely annoying because I have to roll back to version 0.20.14 to push then go back to 0.20.17 to be able to use drizzle studio.