Migrate a workflow type¶
When you ship a new released version of a workflow type, existing
workflows (configured instances) are still pinned to the old
version. Migration is the path that lets a user move their workflow
forward — declared by the new workflow type via migrationRoutes +
migrationRuleSet.
This how-to covers declaring a route, writing the rule set, and verifying.
Prerequisites¶
- Two workflow type versions: the old (already released) and the
new (being prepared). The two share the same
idand differ in version. - A clear sense of which configuration fields renamed / changed shape / got dropped.
Declare the route¶
On the new version's .workflow-type.kts:
workflowType {
metadata {
reference = "<your-namespace>:my-workflow:2.0.0"
// …
}
migrationRoutes {
from("<your-namespace>:my-workflow:1.0.0")
from("<your-namespace>:my-workflow:1.5.0")
}
// …
}
Each from(...) declaration registers an inbound route from a
specific old version. Multiple routes can converge on a single new
version. A bare version reference restricts the route to the released
source (the typical case). To migrate from a snapshot source instead,
give the snapshot-qualified reference, such as
<your-namespace>:my-workflow:1.0.0-SNAPSHOT-latest.
If the migration is just a metadata-bump or a no-op shape change, you can declare the route without a rule set — the framework copies the old configuration verbatim. Most real migrations need a rule set, though.
You do not also declare the old version as a workflowType(...)
dependency. The route is enough: the build resolves the source version
automatically to generate the migration adapters, the registry records it as
a migration source of the new version, and dependencies { } stays limited
to the components the workflow nests at runtime.
Write the rule set¶
The rule set is the actual transformation logic. On the new version's
.workflow-type.kts:
The framework's migration types in framework/values/migration/
provide the building blocks (rename a field, copy a field with
transformation, drop a field, derive a new field from existing
ones). The exact shape is documented in the framework reference.
A small example — renaming edgeLength to meshEdgeLength:
migrationRuleSet {
MigrationRuleSet(
listOf(
// From 1.0.0 to 2.0.0: rename edgeLength → meshEdgeLength
renameField(
from = "edgeLength",
to = "meshEdgeLength",
),
// …additional rules per route as needed
),
)
}
For deeper transformations (e.g. splitting one field into two, deriving a value), see the framework's migration reference.
Build, register, test¶
Once registered, users can migrate a workflow currently at the old version via:
(Or from SimScale Workbench, where the workflow's user can also trigger the migration.)
Verify¶
The cleanest verification is to migrate a real test workflow:
- Have a workflow at the old version with all relevant fields set.
- Run the migrate command against your snapshot (2.0.0-SNAPSHOT)
registered version.
- Inspect the resulting workflow's configuration: every field maps
correctly, no information is lost.
- If the new version pins a newer version of an input's data type,
check the resulting workflow's input data: the referenced items
were migrated to that version along with the workflow (see
data migration).
Snapshots are mutable, so you can re-register the new workflow type freely while iterating on the rule set.
What migration is not¶
- Not for snapshot iteration. Snapshots are mutable; you don't migrate snapshots, you re-register over them.
- Not for data instance shape changes. That's a separate concern (data type versioning + the data type's own validation).
- Not run-time. Migration runs at workflow level, not at workflow-run level. Existing runs of the old workflow keep running on the old workflow type version.
Cross-references¶
- Concepts: migration — the conceptual distinction between routes and rule sets.
- Concepts: components and versions — when you need a migration vs not.
- Release a component — the prerequisite for migration to be useful.