Sourcegraph Upgrade Failed: Dirty Database Migration Error
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. Re-run the migrator
- From 3.37 onward migrations run in the separate migrator service
- Re-run it with --ignore-single-dirty-log to retry the failed migration
- Only mark a migration complete (sg add-log) after verifying it finished
Did this fix it?2. If you skipped a version
- Revert to the last minor version you ran, then follow the supported upgrade path
Did this fix it?3. Get help
- Enterprise customers: support@sourcegraph.com
- 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 usThe same problem in other apps
Other Sourcegraph errors
- Sourcegraph Cody Free and Pro Discontinued: What Happened and What to Do
- Sourcegraph Cody Not Working in VS Code
- Sourcegraph Cody Sign-In Error: Authentication Failed or Signed Out on Restart
- Sourcegraph Cody Not Working in JetBrains (IntelliJ, Android Studio)
- Sourcegraph Cody Rate Limit or Usage Limit Reached
- Sourcegraph Search Not Finding Results
- Sourcegraph Repository Not Cloning or Not Updating
- Sourcegraph Search Slow or Timing Out (Zoekt Crash Loop)