benjiman86
DTDrizzle Team
•Created by benjiman86 on 6/6/2023 in #help
Share migrations in monorepo
Thanks man, this helps. I like the idea with exporting the migration files to the backend. Nevertheless I think I will keep everything inside the core package, as it just feels more consistent. I will run the migrations via CI on deploy and during dev I will just use sth. like nodemon to automatically run migrations.
drizzle-kit
does not have a command yet to execute migrations, right? So I guess I will just write a little script to execute migrate()
then? Also really looking forward for the release of drizzle-kit push
for PostgresSQL.
Thanks again for taking the time and your support! Drizzle is an awesome idea and I hope and guess you will habe great success with it! Defintely like it so far ✌️13 replies
DTDrizzle Team
•Created by benjiman86 on 6/6/2023 in #help
Share migrations in monorepo
Of course, thanks! Looking forward to your ideas.
13 replies
DTDrizzle Team
•Created by benjiman86 on 6/6/2023 in #help
Share migrations in monorepo
Sorry, I of course ment to type Andrew not Andres 😉
13 replies
DTDrizzle Team
•Created by benjiman86 on 6/6/2023 in #help
Share migrations in monorepo
Hey Andres, thanks for your time and the response - I really appreciate this. I made a really simple example repo to illustrate my question: https://github.com/BenBestmann/drizzle-monorepo
The README contains more explanations. The main idea is that I want to encapsulate all database and business logic in an internal packages like the
core
package of the example repo and then use this package in multiple apps of the repo (e.g. web, mobile, backend), see the example Next.js app included (esp. page.tsx
file).
The approach works fine, except for the migrations. I would love to execute them in every app on startup like you illustrate in the docs because I find it very convenient, esp. in development. However as the core
package is just an internal npm workspace with no build, when I execute the Client.migrate()
function from within the apps they are looking for the migrations directory and of course can't find them.
It somehow feels wrong to copy the migrations into every app, as I want the core package to be the single source of truth where I define all schema. Another alternative I can think of is to create a simple npm script in the core
package that runs the migrations which I then manually inovke in development and via a CI solution during deployments.
Do you have any other ideas? I also can think of using your push
command, but we are using Postgres.
Thanks again for taking the time! Best regards, Ben.13 replies