Skip to content

Error codes

js
import { isAlreadyExists, ALREADY_EXISTS_CODES } from "drizzle-migrate-neon-http/errors";

isAlreadyExists(code)

Returns true when a PostgreSQL error code is one of the known "object already exists" conditions that are safe to skip during migration.

Used internally by the runner's executeStatement so that re-running against a partially-applied schema heals rather than explodes.

js
isAlreadyExists("42P07"); // true
isAlreadyExists("23505"); // false — unique violation is NOT skipped

ALREADY_EXISTS_CODES

The exact set:

CodeMeaning
42P07relation already exists
42701column already exists
42710object already exists
42P16cannot change number of columns
42723function already exists
42P17index already exists

Design note

These codes represent desired end states — re-creating an object that's already there. They're intentionally narrow: transient errors, constraint violations (23505) and everything else are re-thrown so real problems surface loudly instead of being silently swallowed.

Released under the MIT License.