Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
24.72k
stars
653
forks
source link
[BUG]: unclear how to correctly define mutual foreign keys (introspection creates invalid schema) #2993
Open
fnimick opened 2 months ago
What version of
drizzle-orm
are you using?0.33.0
What version of
drizzle-kit
are you using?0.24.2
Describe the Bug
Defining tables with foreign keys to each other causes drizzle-kit to output schema that does not type-check.
The following postgres schema:
generates the following schema from introspection:
This fails to type-check due to the table definitions referencing each other in the
extraConfig
function.Expected behavior
Either introspect generates correct schema, or introspect does not generate foreign keys that would cause reference loops.
In addition, documentation on how to handle this when defining schema would be welcome.
Environment & setup