Skip to content

[BUG]: drizzle-kit migrate: migration SQL failures exit with code 1 but print no error (MigrateProgress hides rejection) #5601

@jakubriedl

Description

@jakubriedl

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

beta-20

What version of drizzle-kit are you using?

beta-20

Other packages

No response

Describe the Bug

Describe the bug

When drizzle-kit migrate runs against PostgreSQL and a migration fails because of a SQL error (e.g. the database rejects a statement), the CLI process exits with non-zero (e.g. 1) but does not print the underlying error to stdout/stderr. The last thing you see is the animated “applying migrations…” spinner line, so it looks like a silent failure.

Expected behavior

On migration failure, the CLI should print the same error details users need to fix the migration or the database (at minimum: the message from the failed statement / driver error), similar to other commands that surface errors clearly.

Actual behavior

  • Exit code is non-zero (failure is detectable in CI).
  • No error message is shown; output stops on the spinner line.

How to reproduce

  1. Use drizzle-kit with PostgreSQL (pg driver) and a normal drizzle.config.ts pointing at a database.
  2. Include a migration whose SQL fails when executed (any intentional SQL error is enough — e.g. a statement that the database rejects).
  3. Run drizzle-kit migrate.

Observe: command fails with exit code 1 but no visible error text.

Note: Running the same migrations programmatically via drizzle-orm’s migrate() (e.g. drizzle-orm/node-postgres/migrator) does surface the error, which confirms the failure is real and only the CLI output path is wrong.

Environment

  • OS: (any; observed on macOS)
  • drizzle-kit: (beta / version in use)
  • drizzle-orm: (beta / version in use)
  • Driver: pg / PostgreSQL

Possible cause (for maintainers)

In the bundled CLI, TaskTerminal.reject(err) calls view.render("rejected", err), but MigrateProgress.render appears to only accept status and treats "rejected" the same as "pending" (spinner only), without using the err argument. Other progress views (e.g. introspection) include a branch that prints error.message when status === "rejected".

If that’s accurate, the fix would be to extend MigrateProgress to render the error on rejection, consistent with those other views.

Additional context

This makes debugging failed migrations unnecessarily difficult in local and CI environments because users must bypass the CLI or add wrappers to see the real database error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions