ERROR: column "x" of relation "y" already exists

ALTER TABLE ADD COLUMN for a column that’s already there.

Seen on: PostgreSQL

Meaning

Usually a migration applied twice or manual schema changes.

Common causes

  • Migration re-run
  • Manual change not reflected in migrations

⚡ Quick fix

  1. Use ADD COLUMN IF NOT EXISTS
  2. Reconcile migration history

Detailed fix by platform

PostgreSQL

  1. ALTER TABLE users ADD COLUMN IF NOT EXISTS last_login timestamptz;

How to diagnose

  1. Column — Already present (\d table)?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.