Some tables aren't typed (type any)
For example heres one table:
orgTheme is type any, but most of my other tables have types. Anyone know whats wrong?
when i remove the table function it works fine
15 Replies

I got a type for it, but as you can see I'm missing your
org
table. Maybe your org
table is at fault with a circular dependency
circular importthe org table also is typed any
they are all in the same file. its been introspected
you can try to restart your typescript language server or just restart your vs code instance
i still get type any after doing that
i guess you'll need to show more code then for anyone to help you
the code you gave here worked
if i remove all the foreign keys, it works fine
then something might be in the wrong order, e.g. using a table before it's declared and somehow eslint/ts not catching that? idk
there might be a betterw ay to define a foreign key though
for you'
with a function
because then it's late-bound
the order is possible. theres around 35 tables and lots of referencing org and other tables
All my foreign keys are defined like this:
project_id: text().references(() => projects.id),
ill try adding that to the tables
You can set the options too
Oh also, see that type I used there? For some reason I had to do that at some point but I might be able to undo it now idk why I had that wide type there for AnyPgColumn
(but that same thing might help to untangle the type inference problems)
(btw I added the onUpdate to show u that, it's not my code)
hmm ill try that thanks
wow that worked thanks!! much appreciated @JustWayne 💯
seems introspect doesnt generate the fks properly
https://github.com/drizzle-team/drizzle-orm/issues/2993
this seems like it might be the same issue but there wasnt a solution in it
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...
Niccceee!