Drizzle Kit - Where to store relations?
Seeing as when pull operations occur it overwrites the local schema, is there a good place to keep relations? Just relations.ts somewhere in my project?
6 Replies
I guess this also goes for drizzle-zod stuff too
you shouldn't run
pull
more than once in normal conditions, what's your use case?this is something ive wondered too. not the multiple pulls but related to post title:
should relations be stored in schema.ts
you should keep them in the same place where your schema is stored
you can either store it in a single file or in multiple files, same as with other schema components like tables
it doesn't matter if you keep them next to the tables or not, as long as you use it as a single schema
in my experience, it's most convenient to keep the table's relations next to its table
I'm using pull somewhat strangely. I'm trying to integrate what I've got with Lucia auth, but they require certain tables. Those tables are provided in raw sql, so I run those directly on the db, then pull, then rewrite them. It's pretty niche and once done I shouldn't really need to do it again. I supposed that I can just finish up and then write the relations in a neighboring files called
relations
you can, yes