© 2026 Hedgehog Software, LLC

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

Handling self referencing foreign keys

I have the following code but am getting an error that says

'people' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)

How should I handle a self referencing foreign key like in my example below?

export const people = pgTable("people",{
  id: uuid("id").primaryKey(),
  name: text("name").notNull(),
  parentId: uuid("parent_id").notNull().references(() => people.id)
})
export const people = pgTable("people",{
  id: uuid("id").primaryKey(),
  name: text("name").notNull(),
  parentId: uuid("parent_id").notNull().references(() => people.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

Self referencing
Drizzle TeamDTDrizzle Team / help
3y ago
circular foreign keys
Drizzle TeamDTDrizzle Team / help
3y ago
SQLite self referencing table
Drizzle TeamDTDrizzle Team / help
12mo ago
Self referencing table query
Drizzle TeamDTDrizzle Team / help
2y ago