Sourcegraph Upgrade Failed: Dirty Database Migration Error

Share
Workaround available Self-hosted Updated November 14, 2026Based on 2 user reportsHow we research

Quick answer

If a migration is interrupted the schema is marked dirty; rerun the migrator to retry, and contact support before editing the migration table by hand.

Most likely fix: Re-run the migrator

How to fix it

Try these in order — the most common fix is first.

  1. 1. Re-run the migrator

    1. From 3.37 onward migrations run in the separate migrator service
    2. Re-run it with --ignore-single-dirty-log to retry the failed migration
    3. Only mark a migration complete (sg add-log) after verifying it finished
    Did this fix it?
  2. 2. If you skipped a version

    1. Revert to the last minor version you ran, then follow the supported upgrade path
    Did this fix it?
  3. 3. Get help

    1. Enterprise customers: support@sourcegraph.com
    2. Back up Postgres before any manual change to the schema_migrations table
    Did this fix it?

Symptoms

After a self-hosted upgrade the frontend will not start and logs report a dirty database.

Why it happens

  • Migration interrupted during upgrade
  • Skipped a required minor version
  • Pod killed by a health check during a long migration (older versions)

This guide also covers

  • sourcegraph dirty database
  • sourcegraph upgrade failed
  • sourcegraph migration error

Still not working?

If Sourcegraph keeps failing, you're not alone. See every Sourcegraph problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other Sourcegraph errors

All 11 Sourcegraph errors and fixes →