Problem - Create enums on a file or folder outside of the table
I have a table, and I wanted to test creating enums in a separate folder to share them across multiple tables. The issue was that when I ran drizzle-kit push, I got the following error:
Do we have an explanation for this? I suspect that the table we’re trying to create is instantiated before the enum is created, which is why it’s not being found.
7 Replies
Hey @Cristian Sotomayor! Have you exported this enum from your main schema entry point?
how I can do that ? for example I have an schemas folder and an enum folder.
Right now I'm just using the enum inside the schemas folder and everything works as expected
This is my current drizzle.config.ts file

but I would like to just use the enum from the enum folder and import it on the schemas files.
Is your
enums folder not inside the schemas folder? If so, you should move it there and use the schemas/**/*.ts path.
Or use an array of paths for the schemas property in drizzle.config.ts.yesss it's outside.
Currently is:
So your sugestion is to use something like this:
I would like to add the enums on the schemas path. Like an array
I was writing the message when I saw your answer, so I was looking into the docs for that particular prop and I think I find out what I needed https://orm.drizzle.team/docs/drizzle-config-file#schema
With that examples I can do something like:
I'm going to try that
Drizzle ORM - drizzle.config.ts
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
That seems to be the best option for now — thanks for the help 🙌 Once I know what to check, it’s much easier to figure things out.