diff --git a/packages/prisma-client/migrations-cli/prisma-migrations.ts b/packages/prisma-client/migrations-cli/prisma-migrations.ts index 6283cecbd84c..763284907ba9 100644 --- a/packages/prisma-client/migrations-cli/prisma-migrations.ts +++ b/packages/prisma-client/migrations-cli/prisma-migrations.ts @@ -250,11 +250,13 @@ export const generateMigrationName = (baseName: string) => { }; export const resetDatabase = async () => { - const { stdout: sqlToDeleteEverything } = - await $`"prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-empty --script`; + const { stdout: sqlToDeleteEverything } = await $({ + cwd: prismaDir, + })`"prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-empty --script`; await $({ input: sqlToDeleteEverything, + cwd: prismaDir, })`prisma db execute --stdin --schema ${schemaFilePath}`; await context.prisma.$executeRaw`DROP TABLE IF EXISTS _prisma_migrations`; @@ -262,14 +264,17 @@ export const resetDatabase = async () => { // https://www.prisma.io/docs/reference/api-reference/command-reference#migrate-diff export const cliDiff = async () => { - const { stdout } = - await $`prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-schema-datamodel ${schemaFilePath} --script`; + const { stdout } = await $({ + cwd: prismaDir, + })`prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-schema-datamodel ${schemaFilePath} --script`; return stdout; }; // https://www.prisma.io/docs/reference/api-reference/command-reference#db-execute export const cliExecute = async (filePath: string) => { - await $`prisma db execute --file ${filePath} --schema ${schemaFilePath}`; + await $({ + cwd: prismaDir, + })`prisma db execute --file ${filePath} --schema ${schemaFilePath}`; }; export const generateMigrationClient = async (migrationName: string) => { @@ -293,5 +298,7 @@ export const generateMigrationClient = async (migrationName: string) => { } // https://www.prisma.io/docs/reference/api-reference/command-reference#generate - await $`prisma generate --schema ${schemaPath}`; + await $({ + cwd: prismaDir, + })`prisma generate --schema ${schemaPath}`; };