© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
6 replies
Mads

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",
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

PgColumnBuilderBase and notNull()
Drizzle TeamDTDrizzle Team / help
17mo ago
Conditional NotNull Column?
Drizzle TeamDTDrizzle Team / help
16mo ago
TypeError unless column is notNull
Drizzle TeamDTDrizzle Team / help
13mo ago
notNull(); in a specific condition
Drizzle TeamDTDrizzle Team / help
2y ago