PostgreSQL 42P07: relation already exists
Migration attempted to CREATE TABLE/INDEX that already exists.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.0.0
Identifier: PostgreSQL 42P07: relation already exists
Platform: PostgreSQL
Interactive Diagnostic Checklist
Safe Diagnostic Command:
\dt
Technical Explanation
Migration attempted to CREATE TABLE/INDEX that already exists. Verified technical resolution: Track applied migrations in a schema_migrations table and use `IF NOT EXISTS` for idempotent DDL.
Worked Examples
- Diagnostic check: \dt
Limitations & Assumptions
- Confirm exact software version and execution layer before applying configuration changes in production.
Source References & Verification
Resource ID: err-pg-42p07-duplicate-table · Independently verified: 2026-11-25