notNull and Unique

Hi Whenever I use push:db I get that I am about to add a new unique constraint. I then checked and I don’t actually have the unique constraints set. Am I doing something wrong?
export const companies = mysqlTable('companies', {
id: int('id').autoincrement().primaryKey(),
name: varchar('name', { length: 255 }).unique().notNull(),
owner_id: varchar('owner_id', { length: 255 }).notNull().references(() => users.id),
has_finished_introduction: boolean('has_finished_introduction').default(false).notNull(),
created_at: datetime('created_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
updated_at: datetime('updated_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
})
export const companies = mysqlTable('companies', {
id: int('id').autoincrement().primaryKey(),
name: varchar('name', { length: 255 }).unique().notNull(),
owner_id: varchar('owner_id', { length: 255 }).notNull().references(() => users.id),
has_finished_introduction: boolean('has_finished_introduction').default(false).notNull(),
created_at: datetime('created_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
updated_at: datetime('updated_at').default(sql`CURRENT_TIMESTAMP`).notNull(),
})
"drizzle-kit": "^0.24.2",
4 Replies
🇨🇭 Marko Bolliger <cannap>
i learned one here i just use generate and migrate never push again for me 😄
Mads
Mads3w ago
I have no idea why I am not getting the name as a unique index? Works fine for my other tables.
No description
Mads
Mads3w ago
Moving unique() to the end fixed it: name: varchar('name', { length: 255 }).notNull().unique(), Well that added the unique constraint. But it still complaints about I’m about to add a new unique constraint.
Mads
Mads3w ago
GitHub
[BUG]: Unique key reconciliation with upstream schema is inconsiste...
What version of drizzle-orm are you using? 0.31.2 What version of drizzle-kit are you using? 0.22.8 Describe the Bug Unique keys aren't able to be reconciled properly using Drizzle with PlanetS...
Want results from more Discord servers?
Add your server