drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit migrate prints raw postgres NOTICE objects for successful IF NOT EXISTS migrations
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.45.2
### What version of `drizzle-kit` are you using?
0.31.10
### Other packages
None
### Describe the Bug
## Describe the Bug
When running `drizzle-kit migrate` against PostgreSQL through the `postgres` driver (`postgres.js`), the migration succeeds but raw PostgreSQL `NOTICE` objects are printed to stdout.
This happens when Drizzle executes statements like `CREATE SCHEMA IF NOT EXISTS drizzle` and `CREATE TABLE IF NOT EXISTS drizzle.__drizzle_migrations (...)`. PostgreSQL correctly skips them, but the CLI still prints the NOTICE payloads as plain objects.
### Undesired behavior
`drizzle-kit migrate` reports success, but stdout contains raw objects such as:
```txt
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P06',
message: 'schema "drizzle" already exists, skipping',
file: 'schemacmds.c',
line: '132',
routine: 'CreateSchemaCommand'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P07',
message: 'relation "__drizzle_migrations" already exists, skipping',
file: 'parse_utilcmd.c',
line: '208',
routine: 'transformCreateStmt'
}
```
### Desired behavior
If the migration succeeds, these `NOTICE` messages should either be silenced or handled in a cleaner way by the CLI.
At minimum, successful `IF NOT EXISTS` setup should not dump raw notice objects to the terminal.
### Steps to reproduce
1. Use PostgreSQL with `drizzle-kit migrate`.
2. Ensure the CLI uses the `postgres` driver path, for example with `postgres` installed and `pg` not installed.
3. Run `drizzle-kit migrate` once so the `drizzle` schema and `__drizzle_migrations` table exist.
4. Run `drizzle-kit migrate` again.
5. Observe that the migration succeeds, but raw NOTICE objects are printed.
### Environment
- Database: PostgreSQL
- Runtime: Bun `1.3.12`
- Driver involved: `postgres` / `postgres.js` `3.4.8`
- Not a monorepo
### Additional notes
- This does not appear to be a migration correctness bug. The SQL uses `IF NOT EXISTS` and the migration completes successfully.
- The issue seems specific to the `postgres` driver integration in `drizzle-kit`.
- It looks like `drizzle-kit` creates the `postgres` client without an `onnotice` handler, so `postgres.js` falls back to logging notices to stdout.
- A possible fix would be to pass `onnotice: () => {}` or equivalent filtering when constructing the `postgres` client for CLI migrations.
Contributor guide
Assessment
This issue has not been assessed yet.