Skip to content

Commit

Permalink
fix Prisma migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Aug 9, 2024
1 parent 3f4d613 commit 5bd6b44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix-prisma-migrate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': minor
---

Fix Prisma errors not showing when a Prisma migration errors internally
7 changes: 3 additions & 4 deletions packages/core/src/lib/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type ChildProcess } from 'node:child_process'
import { toSchemasContainer } from '@prisma/internals'

// @ts-expect-error
Expand Down Expand Up @@ -62,9 +61,9 @@ export async function withMigrate<T> (
}
})
} finally {
const closePromise = new Promise<void>(resolve => {
const { child } = migrate.engine as { child: ChildProcess }
child.once('exit', () => resolve())
const closePromise = new Promise<void>(async (resolve) => {
await migrate.engine.initPromise
migrate.engine.child.once('exit', () => resolve())
})
migrate.stop()
await closePromise
Expand Down

0 comments on commit 5bd6b44

Please sign in to comment.