Skip to content

Commit d80748e

Browse files
authored
Fix Prisma errors not showing when a Prisma migration errors internally (#9273)
1 parent 2569f79 commit d80748e

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

.changeset/fix-prisma-migrate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@keystone-6/core': minor
3+
---
4+
5+
Fix Prisma errors not showing when a Prisma migration errors internally

packages/core/src/lib/migrations.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { type ChildProcess } from 'node:child_process'
21
import { toSchemasContainer } from '@prisma/internals'
32

43
// @ts-expect-error
@@ -62,9 +61,9 @@ export async function withMigrate<T> (
6261
}
6362
})
6463
} finally {
64+
await migrate.engine.initPromise
6565
const closePromise = new Promise<void>(resolve => {
66-
const { child } = migrate.engine as { child: ChildProcess }
67-
child.once('exit', () => resolve())
66+
migrate.engine.child.once('exit', resolve)
6867
})
6968
migrate.stop()
7069
await closePromise

packages/core/src/scripts/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export async function dev (
161161
const paths = system.getPaths(cwd)
162162
if (dbPush) {
163163
const created = await createDatabase(system.config.db.url, path.dirname(paths.schema.prisma))
164-
if (created) console.log(`✨ database created`)
164+
if (created) console.log(`✨ Database created`)
165165

166166
const migration = await withMigrate(paths.schema.prisma, system, async (m) => {
167167
// what does force on migrate.engine.schemaPush mean?

tests/cli-tests/migrations.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('dev', () => {
125125
? Server listening on :3000 (http://localhost:3000/)
126126
? GraphQL API available at /api/graphql
127127
? Generating GraphQL and Prisma schemas
128-
? database created
128+
? Database created
129129
? Database synchronized with Prisma schema
130130
? Connecting to the database
131131
? Creating server

0 commit comments

Comments
 (0)