Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamβ€’2y agoβ€’
7 replies
master_codes22

Unique key in PG

Hey guys, sorry I have a little dumb question here πŸ™‚

I wanna know how to set my id field in my PG to auto increament.

Here's my schema;
const apiInventory = pgTable("api_inventory", {
  id: serial("id").primaryKey(), //I want this to auto-increament.
  // other columns and field here...
  status: text("status").notNull(),
  created_at: timestamp("created_at").defaultNow().notNull(),
  last_modified: timestamp("last_modified").defaultNow().notNull(),
});
const apiInventory = pgTable("api_inventory", {
  id: serial("id").primaryKey(), //I want this to auto-increament.
  // other columns and field here...
  status: text("status").notNull(),
  created_at: timestamp("created_at").defaultNow().notNull(),
  last_modified: timestamp("last_modified").defaultNow().notNull(),
});

Someone look this up please, not sure I've found the right docs yet.
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

Unique Key Schema
Drizzle TeamDTDrizzle Team / help
3y ago
generate:pg doesn't create pgEnums
Drizzle TeamDTDrizzle Team / help
3y ago
Making a key in a object with jsonb unique
Drizzle TeamDTDrizzle Team / help
2y ago
Make two columns unique (composite primary key)
Drizzle TeamDTDrizzle Team / help
2y ago