gustav
08/10/2026, 2:38 PMMarvin
08/10/2026, 2:38 PMMarvin
08/10/2026, 2:40 PMPREFECT_SERVER_DATABASE_MIGRATE_ON_START=false
Then run the migration once:
prefect server database upgrade -y
5. For multi-server deployments
If you run multiple Prefect API instances, do not let each instance race to migrate the DB. Use manual migration as above, then start the instances.
6. Watch for large tables
If you have a lot of events, flow_runs, or task_runs, migration/index creation may take longer than expected. Plan a maintenance window and consider increasing migration timeout if needed.
7. Validate after upgrade
After cutover:
- confirm Prefect can connect
- verify the UI/API loads
- run a test flow
- confirm workers pick up work
- monitor DB connections and logs
Important version note
Prefect 3.x self-hosted deployments should use PostgreSQL 14.9+, with PostgreSQL 15+ recommended.
If you want the shortest answer possible:
The safest graceful upgrade is:
- backup
- bring up a new Postgres version
- sync/restore data
- stop Prefect services
- switch the connection URL
- run prefect server database upgrade -y
- start Prefect again
Docs
- Database maintenance
- Scaling self-hosted Prefect
If you want, I can give you a step-by-step runbook for either:
- Docker Compose self-hosted Prefect, or
- Kubernetes / Helm-based Prefect