Skip to content

Commit

Permalink
Fix Prisma errors not showing when a Prisma migration errors interna…
Browse files Browse the repository at this point in the history
…lly (#9273)
  • Loading branch information
dcousens authored Aug 9, 2024
1 parent 2569f79 commit d80748e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 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
5 changes: 2 additions & 3 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 {
await migrate.engine.initPromise
const closePromise = new Promise<void>(resolve => {
const { child } = migrate.engine as { child: ChildProcess }
child.once('exit', () => resolve())
migrate.engine.child.once('exit', resolve)
})
migrate.stop()
await closePromise
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/scripts/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export async function dev (
const paths = system.getPaths(cwd)
if (dbPush) {
const created = await createDatabase(system.config.db.url, path.dirname(paths.schema.prisma))
if (created) console.log(`✨ database created`)
if (created) console.log(`✨ Database created`)

const migration = await withMigrate(paths.schema.prisma, system, async (m) => {
// what does force on migrate.engine.schemaPush mean?
Expand Down
2 changes: 1 addition & 1 deletion tests/cli-tests/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('dev', () => {
? Server listening on :3000 (http://localhost:3000/)
? GraphQL API available at /api/graphql
? Generating GraphQL and Prisma schemas
? database created
? Database created
? Database synchronized with Prisma schema
? Connecting to the database
? Creating server
Expand Down

0 comments on commit d80748e

Please sign in to comment.