using a monorepo with multiple apps and services
i would like to separate my migrations folder with sub directories
for example a shared one where i could move all my shared schema and one sub directory per app name ? is there something remotely close to do that ?
that would help alot for my ci/cd and avoid me to use some kind of post generate script to reorganize my migration folder
4 Replies
i would very much like avoid creating multiple drizzle config file which is also a solution but that looks kind of odd to have ten of those on my root level
I have a setup working now
I isolated all data access concerns into a package called data and there’s a drizzle config within
Also the schema is there and all I expose to the test of the apps are repositories to be used on entities. I use turborepo for task orchestration and Vercel with neon integration so that whenever there’s a change in the data package it runs the generate and migrate into whatever env is deployed to
if you expose all your db queries and entities from the data package you don’t need a drizzle config file anywhere else
i m not sure this answers my issues
when running generate to generate your migrations files it will then create those migrations files for a single db which is fine if you dont have any shared generic models that can also apply to another DB
say for example user model that is shared to app1 and app2
migrations will be created once based on the change they detect right ? so the only way atm is to filter those shared schema and then dispatch them by cloning them to your multiple db
unless there is a more elegant solution ?
ok found an idea
if anyone ever needs something
this way only one drizzle config is required
then using DB_NAME variable i can map them to schemaMap
and manage my migration per app
downside is to write manually all the schema 🙂
ah got it, good point I wasn’t addressing multiple databases