© 2026 Hedgehog Software, LLC

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

relations to the same table

Is this not possible to do?
export const CompaniesRelations = relations(Companies, ({ many, one }) => ({
  clients: many(Companies),
  parentCompany: one(Companies, {
    fields: [Companies.parentCompanyId],
    references: [Companies.id],
  }),
  websites: many(Websites),
}));
export const CompaniesRelations = relations(Companies, ({ many, one }) => ({
  clients: many(Companies),
  parentCompany: one(Companies, {
    fields: [Companies.parentCompanyId],
    references: [Companies.id],
  }),
  websites: many(Websites),
}));


I get an error when rinning the studio:
Error: There are multiple relations between "__public__.Companies" and "companies". Please specify relation name
Error: There are multiple relations between "__public__.Companies" and "companies". Please specify relation name

this error disappears if i remove the self referential relations
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

How do you define one-to-one relations in the same table?
Drizzle TeamDTDrizzle Team / help
3y ago
Reference the same table
Drizzle TeamDTDrizzle Team / help
2y ago
How to reference the same table in the table's definition?
Drizzle TeamDTDrizzle Team / help
2y ago
Relations between tables unclear
Drizzle TeamDTDrizzle Team / help
2y ago