© 2026 Hedgehog Software, LLC

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

Overwriting Schema Defaults

await database.insert(users).values([
  {
    name: ADMIN_NAME!,
    slug: ADMIN_SLUG!,
    email: ADMIN_EMAIL!,
    password: ADMIN_PASSWORD!,
    role: 'ADMIN',
    active: true
  }
])
await database.insert(users).values([
  {
    name: ADMIN_NAME!,
    slug: ADMIN_SLUG!,
    email: ADMIN_EMAIL!,
    password: ADMIN_PASSWORD!,
    role: 'ADMIN',
    active: true
  }
])


the
values function
values function
is marked with an error, because I set role and active, which already have a value due to their default value in the schema.

What can I do about that?

export const users = pgTable('users', {
  id: uuid('id').primaryKey().defaultRandom(),
  name: varchar('name', { length: 256 }).notNull(),
  slug: varchar('slug', { length: 256 }).notNull().unique(),
  biography: text('biography'),
  email: varchar('email', { length: 256 }).notNull(),
  password: varchar('password', { length: 256 }).notNull(),
  role: role('role').notNull().default('STANDARD'),
  active: boolean('active').notNull().default(false),
  createdAt: timestamp('created_at').notNull().defaultNow(),
  updatedAt: timestamp('updated_at').notNull().defaultNow()
})
export const users = pgTable('users', {
  id: uuid('id').primaryKey().defaultRandom(),
  name: varchar('name', { length: 256 }).notNull(),
  slug: varchar('slug', { length: 256 }).notNull().unique(),
  biography: text('biography'),
  email: varchar('email', { length: 256 }).notNull(),
  password: varchar('password', { length: 256 }).notNull(),
  role: role('role').notNull().default('STANDARD'),
  active: boolean('active').notNull().default(false),
  createdAt: timestamp('created_at').notNull().defaultNow(),
  updatedAt: timestamp('updated_at').notNull().defaultNow()
})


Thank you.

Timo
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

Drizzle Schema Defaults
Drizzle TeamDTDrizzle Team / help
3y ago
inferSelect doesnt take into account defaults in schema
Drizzle TeamDTDrizzle Team / help
3y ago
createdAt and expiresAt defaults
Drizzle TeamDTDrizzle Team / help
3y ago
Zod schema validation from Drizzle schema
Drizzle TeamDTDrizzle Team / help
3y ago