[Solved] drizzle-seed autocomplete not working if there are enums or zod objects
Not sure which tag to use for
drizzle-seed
.
I'm trying to seed my database and I was surprised that I wouldn't get table autocomplete inside the seed function when the schema is in different files. Whenever I import * from "./single-file"
everything seems to work. Curiously when I deconstruct the import for a specific table, I lose the autocompelte. The tsconfig is in the comment below.
Case 1 (works) - import * as schema from "./schema/contexts"
Case 2 (doesn't work when the schema is distributed in different files) - import * as schema from "./schema/"
Case 3 (doesn't work when the import is deconstructed - import { contexts } from "./schema/contexts"
Would appreciate any ideas, thanks!1 Reply
Here's the tsconfig:
Initially I thought its because I had drizzle-zod schemas defined within the same files where the table definitions are but it still doesn't work after I've removed them
It's the enums that are breaking it
Turns out anything that is not PgTable (in my case) breaks the autocomplete inside the seed function. When I extracted the tables to a new dbSchema object and pass it to the seed function, the autocomplete works.