monorepo migration folder bundling

I have a turborepo monorepo. Trying to have db as a separate internal package along with its migrations folder but the migrate function uses the migrations folder from the client app rather than the package itself
export const initialMigration = () =>
migrate(db, { migrationsFolder: "../drizzle" });
export const initialMigration = () =>
migrate(db, { migrationsFolder: "../drizzle" });
9 Replies
rphlmr ⚡
rphlmr ⚡5mo ago
Where is initialMigration? From where is it executed? Reading it like that, I guess it tries to migrate the content of a drizzle folder one level up from this function's location.
Luka
LukaOP5mo ago
initialMigration declaration is in the package but is called from the app
rphlmr ⚡
rphlmr ⚡5mo ago
I would try a path from the root of the repository. I wonder if someone already did that
rphlmr ⚡
rphlmr ⚡5mo ago
GitHub
GitHub - BenBestmann/drizzle-monorepo
Contribute to BenBestmann/drizzle-monorepo development by creating an account on GitHub.
rphlmr ⚡
rphlmr ⚡5mo ago
He seems to have the same issues Now I want to try it myself 😏
Luka
LukaOP5mo ago
yeah found one other as well
Luka
LukaOP5mo ago
Stack Overflow
How to best manage migrations with Drizzle ORM in a Monorepo?
How do you best manage/execute database migrations if the same database is being used within multiple projects? Some background: I have a project with a monorepo structure build with Turborepo on t...
Luka
LukaOP5mo ago
tried getting it thru absolute paths rather than relative one but __dirname doesnt work with nextjs since the dev is running in a .next folder rather than the project root
export const initialMigration = () => {
const migrationsFolder = path.resolve(
process.cwd(),
"../../packages/db-web/drizzle",
);

return migrate(db, { migrationsFolder });
};
export const initialMigration = () => {
const migrationsFolder = path.resolve(
process.cwd(),
"../../packages/db-web/drizzle",
);

return migrate(db, { migrationsFolder });
};
come up with this seems to be a weird issue
rphlmr ⚡
rphlmr ⚡5mo ago
It doesn’t surprise me but I agree it would be better to have something simpler (in turbo or some args on migrate)
Want results from more Discord servers?
Add your server