Two tables that references each other
How can I do two tables that references each other?
I have provided a minimal example to showcase what I am trying to achieve.
But when doing this I get a typescript error for both table_1 and table_2
How can I solve this?
2 Replies
You need to cast the reference using the ‘AnyPgColumn’
for example:
‘’’
table_2_ref: uuid("table_1_ref").references((): AnyPgColumn => table_2.id)
‘’’
more details: https://orm.drizzle.team/docs/indexes-constraints
Drizzle ORM - Indexes & Constraints
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Thanks for the information!