drizzle-team / drizzle-team/drizzle-orm
[BUG]:Multiple primary key defined
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.45.1
### What version of `drizzle-kit` are you using?
0.31.8
### Other packages
_No response_
### Describe the Bug
### where my query is too simple but i faced this peoblem.
`
pnpm drizzle-kit push
No config path provided, using default 'drizzle.config.js'
Reading config file '/Users/walter/git3/rimubhai3/drizzle.config.js'
[✓] Pulling schema from database...
Reading schema files:
/Users/walter/git3/rimubhai3/lib/db/schema.js
Error: Multiple primary key defined
at PromiseConnection.execute (/Users/walter/git3/rimubhai3/node_modules/.pnpm/mysql2@3.16.0/node_modules/mysql2/lib/promise/connection.js:47:22)
at Object.query (/Users/walter/git3/rimubhai3/node_modules/.pnpm/drizzle-kit@0.31.8/node_modules/drizzle-kit/bin.cjs:81040:40)
at mysqlPush (/Users/walter/git3/rimubhai3/node_modules/.pnpm/drizzle-kit@0.31.8/node_modules/drizzle-kit/bin.cjs:84265:22)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.handler (/Users/walter/git3/rimubhai3/node_modules/.pnpm/drizzle-kit@0.31.8/node_modules/drizzle-kit/bin.cjs:93840:9)
at async run (/Users/walter/git3/rimubhai3/node_modules/.pnpm/drizzle-kit@0.31.8/node_modules/drizzle-kit/bin.cjs:93117:7) {
code: 'ER_MULTIPLE_PRI_KEY',
errno: 1068,
sql: 'ALTER TABLE `about` ADD PRIMARY KEY(`id`);',
sqlState: '42000',
sqlMessage: 'Multiple primary key defined'
}
`
### here is my query
`
import { boolean, int, mysqlTable, text, timestamp, varchar } from "drizzle-orm/mysql-core";
export const users = mysqlTable("users", {
id: int("id").autoincrement().primaryKey(),
name: varchar("name", { length: 256 }).notNull(),
email: varchar("email", { length: 256 }).unique().notNull(),
password: varchar("password", { length: 256 }).notNull(),
role: varchar("role", { length: 50 }).default("ADMIN"),
createdAt: timestamp("created_at").defaultNow(),
});
export const about = mysqlTable("about", {
id: int("id").autoincrement().primaryKey(),
title: varchar("title", { length: 255 }).notNull(),
content: text("content").notNull(),
published: boolean("published").default(false),
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow(),
});
`
Contributor guide
Assessment
This issue has not been assessed yet.