Srul Pinkas
06/03/2026, 11:23 AMMarvin
06/03/2026, 11:23 AMMarvin
06/03/2026, 11:25 AMbash
prefect server database upgrade -y
I verified that command exists. You can also inspect it with:
bash
prefect server database upgrade --help
A few important details:
What happens to old runs?
- Existing historical runs should remain in the database and stay visible after upgrade
- Logs, states, artifacts, and most server-side metadata are intended to be preserved
- Prefect 3 upgrades the schema/data rather than replacing the DB
Do you need to migrate the inner Prefect DB?
- Yes
- If you're using the same self-hosted Postgres/SQLite database, run the DB upgrade after installing Prefect 3
- For production/self-hosted Postgres, definitely backup first
Typical upgrade flow:
bash
# stop old server / API processes first
pip install -U prefect
prefect server database upgrade -y
# then start Prefect 3 server
prefect server start
Big caveat: server data may migrate cleanly, but execution infrastructure may not be plug-and-play.
In particular for Prefect 3:
- agents -> workers is the big conceptual shift
- old deployment patterns from Prefect 2 often need updating
- do not use removed 2.x patterns like Deployment.build_from_flow() or prefect deployment build
- use flow.from_source(...).deploy(...) or prefect deploy instead
So I’d separate the upgrade into two questions:
1. Server/database/history: usually yes, migrate and keep historical data
2. How flows are deployed/run going forward: may require changes
A few cautions:
- Backup the DB first
- test in staging if the database is important
- if you have a large database, migrations may take a while
- if you run multiple API/server instances, disable auto-migrate on startup and run migration once before bringing them all up
Useful docs:
- Prefect server CLI
- Prefect 3 deployments
- Upgrade to Prefect 3
If you want, I can also give you a Prefect 2 -> 3 self-hosted upgrade checklist for either:
- docker-compose server
- kubernetes
- or bare-metal / venv install