drizzle-team / drizzle-team/drizzle-orm

[BUG]: drizzle-kit migrate CLI silently fails with exit code 1 - SQL errors not printed

Open
#5,521 9 comments 54 reactions 0 assignees View on GitHub
bug/fixed-in-beta
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.45.1

### What version of `drizzle-kit` are you using?

0.31.10

### Describe the Bug

When running `drizzle-kit migrate` (CLI), if a SQL migration statement fails, the command exits with **exit code 1** but **does not print the actual PostgreSQL error**. Only `NOTICE` messages from earlier statements are shown, leaving the user with no indication of what went wrong.

### Steps to Reproduce

1. Define a schema with a `vector(4096)` column and an HNSW index:

```ts
import { pgTable, uuid, text, vector, index } from "drizzle-orm/pg-core";

export const notes = pgTable(
'notes',
{
id: uuid('id').primaryKey().defaultRandom(),
content: text('content').notNull(),
embedding: vector('embedding', { dimensions: 4096 }),
},
(table) => [
index('embeddingIndex').using('hnsw', table.embedding.op('vector_cosine_ops')),
]
);
```

2. Run `npx drizzle-kit migrate`

### Actual Behavior

```
applying migrations...{ severity_local: 'NOTICE', code: '42P06', message: 'schema "drizzle" already exists, skipping' }
applying migrations...{ severity_local: 'NOTICE', code: '42P07', message: 'relation "__drizzle_migrations" already exists, skipping' }

Command exited with code 1
```

The real PostgreSQL error is completely hidden. No error message, no stack trace — just a silent failure.

### Expected Behavior

The actual SQL error should be printed to the console. When manually executing the same SQL statements against the database, the real error is revealed:

```
ERROR: column cannot have more than 2000 dimensions for hnsw index
```

This is because pgvector's HNSW index supports a maximum of **2000 dimensions** for the `vector` type, but the migration attempts to create an index on a `vector(4096)` column. The user has no way to know this from the CLI output alone.

The CLI should always surface the underlying database error so users can diagnose and fix their schema.

### Workaround

Manually execute the migration SQL statements directly against the database to reveal the actual error. The root cause in this specific case is the pgvector HNSW 2000-dimension limit, but the silent failure is a drizzle-kit bug regardless of the underlying SQL error.

### Environment

- **Database**: PostgreSQL + pgvector (Supabase)
- **OS**: macOS
- **drizzle-orm**: 0.45.1
- **drizzle-kit**: 0.31.10
- **Runtime**: Bun

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with `drizzle-kit migrate` and the `vector(4096)` HNSW migration described in the issue, then trace the CLI's PostgreSQL migration error handling. Confirm how the underlying SQL error is caught or displayed. Done means the actual PostgreSQL error, rather than only NOTICE messages and exit code 1, is printed to the console.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, postgresql, typescript
Domain
cli, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.