`migrate dev` hangs on the migration name prompt when stdin is not a TTY

Open
#30,940 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
30/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
nodejs, sqlite, typescript
Domain
cli, databases

Research direction

The bug is in packages/migrate/src/utils/promptForMigrationName.ts, around line 21, where the non-interactive check tests the isInteractive function without calling it. Other commands use canPrompt() for this check, which the reporter suggests reusing. Done means npx prisma migrate dev < /dev/null creates the migration with the default name and exits instead of waiting at the prompt. The reporter already links a fix in PR 30941, so check that before starting.

Written by the indexing model from the issue text.

Description

bug/1-unconfirmed kind/bug
Package and version

[email protected]

What happened?

prisma migrate dev without --name hangs forever on "Enter a name for the new migration:" when stdin is not a terminal (e.g. if it's a script or a coding agent).

What did you expect to happen?

The prompt should be skipped and the migration created with the default empty name, same as when CI=1 is set.

Minimal reproduction
Repro in arbitrary project

If you already have a Prisma project at hand, just change the schema to trigger a migration and then run npx prisma migrate dev < /dev/null. Prisma will prompt for a migration name and then hang.

Full repro

Project setup:

mkdir repro && cd repro && npm init -y
npm i -D [email protected] && npm i @prisma/[email protected]

cat > schema.prisma <<'EOS'
generator client {
  provider = "prisma-client"
  output   = "./generated"
}
datasource db {
  provider = "sqlite"
}
model User {
  id Int @id @default(autoincrement())
}
EOS

cat > prisma.config.ts <<'EOS'

import { defineConfig } from "prisma/config";
export default defineConfig({
  schema: "schema.prisma",
  migrations: { path: "migrations" },
  datasource: { url: "file:./dev.db" },
});
EOS

Broken behavior:

npx prisma migrate dev < /dev/null
# prints "? Enter a name for the new migration: ›" and never exits

Working behavior:

CI=1 npx prisma migrate dev < /dev/null
# ccreates the migration with the default name and exits 0
Environment
  • Node: 24.14.1
  • OS: EndeavourOS (Arch Linux), kernel 7.2.2
  • Package manager: npm 11.19.0
  • Database: SQLite (file:./dev.db)
  • Schema Engine: schema-engine-cli d1b3f377ca835d73fd50954a5e22128b9ebdd6b8
Additional context

This happens because the check that should skip the prompt forgets to call the isInteractive function which always results in a falsy value. The condition should be !isInteractive(), not !isInteractive:
https://github.com/prisma/orm/blob/97ea359250335c1a174504c9b2b7e5fe030ab937/packages/migrate/src/utils/promptForMigrationName.ts#L21

This has been broken since https://github.com/prisma/orm/pull/15008.

Instead of fixing the call to isInteractive, the cleaner fix is to just call the canPrompt() function. All other commands already do this. I fixed this in https://github.com/prisma/orm/pull/30941.

Dominant language
TypeScript
Stars
47.8k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
227

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prisma/orm

All issues in prisma/orm

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.