Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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