using mysql for drizzle.
When executing an insert statement with drizzle, a default value is inserted into the autoincrement field, resulting in the error message “Duplicate entry ‘0’ for key ‘user.PRIMARY'”.
my schema as below
export const user = mysqlTable("user", {
id: int("id").primaryKey().autoincrement(),
name: text("name"),
});
my code as below
connection obejct is mysql2.createPool function value.
drizzle(connection, { logger: true });
here is log.
Query: insert into `user` (`id`, `name`) values (default, ?) -- params: ["test"]
Error: Duplicate entry '0' for key 'user.PRIMARY'
any advice will be appreciated. I have been wasting hours…