Upgrades and workflow versions
- Immutable versions: a deployed
nameandversionnever changes; raiseversionwhen code or bundled dependencies change. - Forward-only migrations: PostgreSQL migrations run automatically on startup and cannot roll back — always back up the database before upgrading.
- Reviewed access pins: compile and verify
authorization.tsin staging, pinauthorization.activate.digest, and reviewauditorgrants on every upgrade.
Use this guide whenever you deploy updated Workflow Definitions, plan a version
change while instances are running, or upgrade the IdentityFlow program on your
servers. For initial VM installation, PostgreSQL provisioning, systemd, and TLS
reverse-proxy setup, see Install and run IdentityFlow.
For container builds and Kubernetes Recreate deployments, see
Containers and Kubernetes.
The program deploys Workflow Definitions when it starts.
To deploy a new or changed definition, update the workflow project on the
server (using npm ci from the same lockfile verified in
CI) and restart the program.
The program searches workflows.path below workflows.cwd (by default, the
directory of the configuration file) for files matching
**/*.{request,approval,flow,workflow,wf}.?(m)[jt]s or
**/workflows/*.?(m)[jt]s. Test files, hooks files, node_modules, and the
other excluded paths in the
configuration reference
are skipped.
The program deploys only the default export of each file, so one file holds one
workflow. A file without a valid default export is skipped with the log line
workflow bundle invalid. Each name belongs to one file: when two files
declare the same name, the program logs workflow bundle name conflict, and
which of the two it deploys is not defined.
A Workflow Definition is a draft unless it sets draft: false. The program
skips drafts and logs Skipping deployment of draft workflow:. Set
draft: false when a definition is ready to run.
Each deployed definition is identified by its name and version. A deployed
version is immutable:
- Changed bundle stops startup: if a workflow file or its bundled
dependencies change while its
nameandversionstay the same, startup stops withWF_DEFINITION_BUNDLE_CHANGED:Workflow Definition "<name>" version "<version>" has a different bundle. … Raise the version before starting. - Explicit versions: if a definition omits
version, the program assigns0.0.0+<hash>, which changes with every bundle change. Set an explicit semantic version so logs, UI screens, and audit trails show which release ran. - Permanent storage: deployed versions stay in PostgreSQL permanently. IdentityFlow has no way to remove a deployed version.
How running instances move between versions
Section titled “How running instances move between versions”Versions follow semantic versioning, and running instances follow it too. Each
time a running instance of a project-deployed Workflow Definition continues —
for example after a dialog answer or timer wake — IdentityFlow runs it with the
newest deployed version in the same release channel that satisfies
^<its current version>:
- From
1.0.0onward,1.0.1and1.1.0are compatible with1.0.0;2.0.0is a new major version and is not compatible. - Below
1.0.0, the caret range is narrower:0.2.0is not compatible with0.1.0, and0.0.4is not compatible with0.0.3. - Definitions registered directly inside a Workflow Test do not move between
versions; they stay on the exact version passed to
workflowTest(...).
A minor or patch version must therefore remain safe for every instance that started on an earlier version of the same major:
- Parameters and decoded results: its params schema must accept every value older versions accepted, because IdentityFlow validates recorded start parameters again on every continuation. Schemas that decode already-recorded step or dialog results must still accept those recorded values.
- Recorded steps: steps that already ran must keep their names, kinds
(
do,sleep,dialog,request,start), and order. Add new steps only after existing steps or inside branches older instances never reached. - Breaking changes need a new major version: renaming, removing, or
reordering steps, changing a step’s kind, or tightening a params or dialog
schema requires a new major version (or a new minor version below
1.0.0). Instances on the old major keep running on their stored version from PostgreSQL.
Change a definition in place: edit its file and raise version. Do not keep
the old version in a second file or second export. IdentityFlow loads older
versions from PostgreSQL whenever existing instances continue, even after the
old code is no longer in your project.
See Deploy a new version of a workflow for a complete
tested example (including adding optional parameters across paused dialogs) and
Replay rules for deterministic
authoring rules. In the web application, the line under an instance’s title
shows <name>@v<version> · <release channel>, and the Operations list shows
v<version>.
The program migrates the PostgreSQL database itself on every start. All pending
migrations run in one transaction under an exclusive lock on the migrations
table, using the NOSUPERUSER database-owner role provisioned during setup.
Migrations only go forward. A program refuses a database that a newer program
has migrated and stops with WF_DATABASE_MIGRATION_MISMATCH:
Database was migrated by a newer or incompatible IdentityFlow program, or its migration history has a gap.
The message names the recorded migration key and the newest key the program
knows.
To recover from a mismatch, start the program version that migrated the database or restore a backup taken before the upgrade. Always back up PostgreSQL before starting a new IdentityFlow program version.
The canonical-identity contract changes every newly compiled identity once, including unchanged Workflows and Access Configurations. Prepare this transition before deploying the new IdentityFlow program:
- Raise each affected Workflow Definition version. Use a compatible minor or patch only when running instances can safely replay against it under the versioning rules.
- Compile the Access Configuration in a preparation deployment with
authorization.activateabsent, or in your deployment build. Review the inert Candidate and its source. Omitting activation leaves the existing active revision intact; do not remove a production pin to activate unseen code. - Replace
authorization.activate.digestwith the newly reviewed digest while retaining the reason and Account attribution. Deploy that pin, the new Workflow versions, and the new IdentityFlow program together. - Check startup and the deployed versions. A stale pin still refuses before the already-active shortcut. An equal active Candidate does not need another Access Configuration Revision.
Existing Events, Workflow Definitions, stored bundles, and audit history stay unchanged. Retained bundles remain executable, and running instances continue under the existing compatibility rules. Hook provenance changes once: relation projections may refresh, and stale required-version evidence may temporarily deny access until reconciliation. Keep that fencing in place.
Follow this sequence whenever you upgrade the IdentityFlow program or deploy a new project release to production:
- Back up PostgreSQL first. Database migrations are forward-only; a pre-upgrade backup is your rollback path.
- Read the release notes. Check Release overview and Version history for breaking changes, migration requirements, and schema updates.
- Test against the target release in CI. Pin
@identity-flow/api,@identity-flow/sdk,@identity-flow/binding-graphql, and@identity-flow/testingto the target release version, install withnpm ci, and pass type checks,*.test.ts, and*.case.tsagainst the matching Workflow Test distribution (CI for workflow projects). - Bump changed Workflow Definition versions. Equal source, compiler
settings, and executable module graphs produce equal bundles across package
managers, but dependency upgrades or peer changes can alter a compiled
bundle and trigger
WF_DEFINITION_BUNDLE_CHANGED. Raise theversionof every affected definition before rollout. - Review
authorization.ts, digest pins, andauditorgrants. Verify the compiled Access Configuration digest in staging before pinningauthorization.activate.digestin production (Access control). Confirm thatauditorgrants stay restricted to people authorized to read recorded eventdatapayloads as well as metadata (Read an audit trail). - Stop old instances before starting the new release. Never mix different
program builds against one database. On VMs, wait for clean shutdown
(Stop the program); on Kubernetes,
rely on
strategy.type: Recreate(Containers and Kubernetes). - Verify readiness and record deployed versions. Confirm
/-/readyreturnsready 200, check startup logs for activated definitions and access revisions, and record which workflow versions were deployed and when so audit reviews can correlate steps with deployed code.
Only for an installation that runs 0.2.0 today. The upgrade changes the
database in one direction; back up first.
Upgrade steps from 0.2.0 and how to go back
The upgrade changes the database in one direction.
- Back up the database.
- Stop the
0.2.0program. - Update the npm packages in your project to
0.3.1and runnpm ci. - Be ready for
WF_DEFINITION_BUNDLE_CHANGED.0.2.0silently kept the stored bundle when a file changed under an existing name and version; newer releases stop the start instead. New package versions can change the bundle of a definition whose source you did not touch. Raise the version of each definition the message names: a patch version when its behavior is unchanged, because running instances move to it. If the named definition is an older version of a line that already has a newer one, stop exporting it instead: its instances move to the newest version of the line, and its stored bundle stays in the database. - Check the configuration against the
configuration reference. If no Access
Configuration is active in the database yet, add an
authorizationblock withactivate, or nobody reaches the workflow catalog; see Access control. - Start the
0.3.1program. It migrates the database.
After step 6, the 0.2.0 program cannot use the database; it fails with
42723: function "uuid_generate_v7" already exists with same argument types.
To go back, restore the backup from step 1. The complete list of changes is on
the release overview page.