Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prisma migrate cli regression error #8898

Merged
merged 2 commits into from Nov 14, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-llamas-sparkle.md
@@ -0,0 +1,5 @@
---
'@keystone-6/core': patch
---

Fix prisma migrate non-interactive environment error
34 changes: 14 additions & 20 deletions packages/core/src/scripts/prisma.ts
@@ -1,4 +1,4 @@
import { execFile } from 'node:child_process';
import { spawn } from 'node:child_process';
import esbuild from 'esbuild';
import { createSystem } from '../lib/createSystem';
import {
Expand All @@ -23,25 +23,19 @@ export async function prisma(cwd: string, args: string[], frozen: boolean) {
await generateTypescriptTypesAndPrisma(cwd, config, graphQLSchema);

return new Promise<void>((resolve, reject) => {
const p = execFile(
'node',
[require.resolve('prisma'), ...args],
{
cwd,
env: {
...process.env,
DATABASE_URL: config.db.url,
PRISMA_HIDE_UPDATE_MESSAGE: '1',
},
const p = spawn('node', [require.resolve('prisma'), ...args], {
cwd,
env: {
...process.env,
DATABASE_URL: config.db.url,
PRISMA_HIDE_UPDATE_MESSAGE: '1',
},
err => {
if (typeof err?.code === 'number') return reject(new ExitError(err.code));
if (err) return reject(err.code);
resolve();
}
);

p.stdout?.pipe(process.stdout);
p.stderr?.pipe(process.stderr);
stdio: 'inherit',
});
p.on('error', err => reject(err));
p.on('exit', code => {
if (code) return reject(new ExitError(code));
resolve();
});
});
}