How do you define two tables that have foreign keys to each other? drizzle-kit introspect fails
Drizzle-kit now generates a schema file with type errors - it was previously working prior to 0.24.0.
In addition, the generated foreign key entry for multicolumn foreign keys has the columns in the incorrect order.
(code below due to length limit)
2 Replies
sql source to generate tables:
generated schema that fails:
note that:
- this doesn't compile due to the mutual references causing type errors in inference
- in addition, the generated
testKey
on child
has the columns in inverse ordercreated issue for mutual foreign keys: https://github.com/drizzle-team/drizzle-orm/issues/2993
created issue for introspect reversing column order: https://github.com/drizzle-team/drizzle-kit-mirror/issues/574
GitHub
[BUG]: unclear how to correctly define mutual foreign keys (introsp...
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 sch...
GitHub
postgres: drizzle-kit introspect generates multi column foreign key...
The following SQL: create schema drizzle_test; create table drizzle_test.parent ( id uuid primary key default uuid_generate_v4(), other_id uuid not null, unique (id, other_id) ); create table drizz...