Upgrade checks¶
Open Forms has upgrade checks built-in to prevent inconsistent database states. This consists of a couple of components, given that:
You are currently on version
X
andyou are trying to upgrade to version
Y
Then, the check will:
Validate that upgrading from version
X
to versionY
is a supported upgrade path.Run specified check management commands - if any command raises
CommandError
, the upgrade is blockedRun specified check scripts from the
bin
folder
Check configuration¶
The upgrade paths are specified in openforms.upgrades.upgrade_paths
, in the
UPGRADE_PATHS
constant.
For every target version (=version to upgrade to), you can specify:
the supported version ranges to upgrade from
management commands that need to pass (optional)
custom scripts in the
bin
folder that need to pass (optional)
Custom scripts
Custom scripts must implement a main
callable, taking the skip_setup
boolean
(keyword) argument. If the function returns False
or raises an exception, then the
upgrade is blocked.
How does it work?¶
The version ranges are specified in semantic version format, and thus primarly target official releases.
Note
Non-official releases are possible in the form of custom image builds, or even development/nightly builds that don’t have an explicit version number.
When a release is created, it is assigned an explicit version number (see also: Versioning policy) in semantic version format, e.g.:
1.0.0
,2.0.0-beta.1
…The CI pipeline bakes this version number into the container image in the
RELEASE
environment variable (and the VCS commit hash is baked intoGIT_SHA
, accordingly)The container start script (
bin/docker_start.sh
) runs migrations as part of the initialization, through themigrate
management command.Django runs the system checks before executing the migrations
Our custom system check is registered with the system checks and runs as part of the system checks
The custom check reads from the database which version was deployed earlier and compares this with the version from the container image (from the
RELEASE
environment variable). The check then verifies if upgrading from old version (from the database) to the new version is possible.If upgrading is not possible, an error is emitted and the
migrate
command does not execute - your database is thus left untouched. Because of the error exit code, the container will also not start. All information to correct this situation is available in the container logs.If upgrading is possible, migrations are executed and add the end the version registered in the database is automatically updated with the value of
RELEASE
This cycle repeats for the next upgrade.
If your upgrade is blocked, you should be able to safely deploy the old version again, make the necessary changes to resolve the problems preventing the upgrade, and then try again.
Developers and people deploying latest
(don’t do this unless you’re willing to
debug breaking changes!) usually receive warnings instead of errors, so their usual
flow is not broken.