© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•15mo ago
pandareaper

serial('id').primaryKey() vs primaryKey() in extraConfig?

Are there any implications with marking a column as a primary key through the
extraConfig
extraConfig
argument as opposed to on the column definition?

If I define a column like the following, everything seems to behave fine, but I do see that in the snapshot that drizzle marks the column as
primaryKey: false
primaryKey: false
and instead considers this a composite PK

export const my_table = pgTable(
  'my_table',
  {
    id: serial('id').primaryKey(),
  }, 
  (table) => ({
    pk: primaryKey({ columns: [table.id] }),
  })
)
export const my_table = pgTable(
  'my_table',
  {
    id: serial('id').primaryKey(),
  }, 
  (table) => ({
    pk: primaryKey({ columns: [table.id] }),
  })
)
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

`id` type is `undefined` when using `serial("id").primaryKey()`
Drizzle TeamDTDrizzle Team / help
2y ago
Duplicate indexes when using `serial('').primaryKey()`
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle schema vs SQL when migrating serial id to uuid?
Drizzle TeamDTDrizzle Team / help
2y ago