Edgeweir
Operations

Downgrade

Conditions, steps, and risks of returning the console and nodes to an earlier version; crossing a migration needs the pre-upgrade backup.

When a downgrade is possible

Between the two versionsMethodData
No new migrationsSet the image tag back to the old version and recreate the container; see direct downgradeKept
New migrationsRestore the pre-upgrade backup, then start the old version; see downgrade from a backupEvery change after the backup is lost

The console does not check whether the database schema is newer than the image: an old image on a migrated database finds no pending migration, starts normally, and fails when it reads or writes new or changed tables. Do not only switch back to the old tag when there are new migrations.

Migration rules

ItemRule
Locationpackages/db/migrations/<number>_<name>.sql, ordered in packages/db/migrations/meta/_journal.json
RecordTable drizzle.__drizzle_migrations: one row per applied migration (hash, created_at)
At startupApplies the migrations whose created_at is later than the last record, all in one transaction that rolls back on failure
DirectionForward only; no down scripts
Release notesThe "Compatibility" section of a stable GitHub Release lists the migrations it adds

Checking for new migrations

Method 1, compare the two commits in a repository checkout (the commit ID is the part of the tag after -):

git diff --name-only <old commit> <new commit> -- packages/db/migrations/

No output means no new migrations.

Method 2, compare the migrations applied to the database with the old version's count:

docker compose exec -T postgres psql -U edgeweir -d edgeweir -Atc \
  'select count(*) from drizzle.__drizzle_migrations'
git show <old commit>:packages/db/migrations/meta/_journal.json | jq '.entries | length'

Equal numbers mean no new migrations; a larger database count means new migrations.

Direct downgrade

For two versions without new migrations between them.

DeploymentAction
Docker ComposeSet EDGEWEIR_VERSION in .env back to the old tag and run docker compose up -d
deploy.sh./deploy.sh update <old tag>; when the target is older than the current version the script warns and asks whether to continue (default no); see the deploy.sh reference
docker runRecreate edgeweir-console with the same options and the old tag
Railway, Fly.io, bunny.net, Render, ZeaburSet the image tag to the old dated tag and redeploy; see the "Upgrade" section of each platform page

Verify: version in curl -s http://127.0.0.1:3000/healthz is the old tag.

Downgrade from a backup

For two versions with new migrations between them. Needs the pre-upgrade database backup (deploy.sh update writes it to backups/<time>-before-<new tag>/) and the master key at backup time.

deploy.sh

  1. Set EDGEWEIR_VERSION in .env back to the old tag.

  2. Restore the pre-upgrade backup:

    ./deploy.sh restore backups/<time>-before-<new tag>

    The script backs up the current database, stops the console, drops and recreates the database, imports the backup, and starts the version in .env; see the deploy.sh reference.

Docker Compose

  1. Stop the console:

    docker compose stop console
  2. Back up the current database (to return to the new version if the downgrade fails):

    umask 077
    docker compose exec -T postgres pg_dump -U edgeweir -d edgeweir --format=custom > edgeweir-after-upgrade.dump
  3. Drop and recreate the database:

    docker compose exec -T postgres dropdb -U edgeweir --force edgeweir
    docker compose exec -T postgres createdb -U edgeweir edgeweir
  4. Import the pre-upgrade backup:

    docker compose exec -T postgres pg_restore -U edgeweir -d edgeweir --exit-on-error < edgeweir.dump
  5. Set EDGEWEIR_VERSION in .env back to the old tag and start:

    docker compose up -d
  6. Check as in verification after a downgrade.

For external PostgreSQL and platform databases, restore into a new database as in backup and recovery, point DATABASE_URL at it, and deploy the old tag.

Lost data

These changes made after the backup are not in the restored database:

DataAfter the restoreAction
Changes to sites, rules, certificates, DNS, and other configurationBack to their state at backup timeRepeat them
Nodes enrolled after the backupThe database does not know them; they cannot connectEnroll again on the node with a new install command plus --force
Certificates issued or renewed after the backupThe database holds the certificate at backup time; nodes switch to it with the next published configurationRequest certificates added after the backup again; click "Renew now" for certificates close to expiry
Audit logs, access logs, statistics, alert recordsMissing after the backup—
Configuration revision numbersNodes may have applied a revision higher than the latest in the databasePublish a configuration once; see resynchronize nodes

Verification after a downgrade

CheckPass condition
Version/healthz returns "status":"ok" and the old tag as version
MigrationsRows in drizzle.__drizzle_migrations equal the entries of the old version's _journal.json
Logdocker compose logs console has no "level":"error" lines
NodesNodes under Clusters & nodes are "Online"; "In sync" after one published configuration

Node downgrade

Node versions are independent of the console; a console downgrade does not require a node downgrade.

MethodConditions and steps
Automatic rollbackWhen a signed upgrade's candidate does not pass its health check within 90 seconds, the supervisor restores the previous program, Lua, and configuration snapshot; no action needed; see supervisor and rollback
Upgrade task to an older versionNodes refuse versions older than the running one ("Version … was rejected; the previous version is kept"). Set EDGEWEIR_UPGRADE_ALLOW_DOWNGRADE=true in the node's /etc/default/edgeweir-node and run systemctl restart edgeweir-node; when no node is below the target version, the console's "New upgrade" dialog cannot be submitted, so start it through the API POST /api/v1/node-upgrades (version, nodeGroupId). Remove the setting afterwards
Reinstalling an older package or imageThe supervisor sees that the base installation changed and uses the newly installed program and Lua; an unconfirmed upgrade task is recorded as "The task for version … was superseded by a local package update"

A node's identity key, certificate, credentials, and statistics cursors do not go back with the program. A node downgraded to a version without a capability the cluster's current configuration needs shows "Upgrade required" and serves its last good configuration.

Risks

RiskDescription
Only switching back the tagWith new migrations, old code runs on the new schema; requests and background jobs fail and data may be written inconsistently
Data lossA downgrade from a backup loses every change after the backup; see lost data
Master keyA restore needs the master key at backup time; if the key was rotated after the backup, set the old key as EDGEWEIR_MASTER_KEY_PREVIOUS; see master key rotation
Session secretBETTER_AUTH_SECRET must match the backup; otherwise every session ends and two-factor codes cannot be verified
Several instancesDowngrade all console instances together; instances of different versions cannot share a database
Security fixesThe old version lacks security fixes released since
Node capabilitiesThe old console does not know capabilities newer nodes report; connections are not affected
Edit on GitHub

On this page