Class Actions
Actions for changes to the classes objects carry. How upgrades are declared, ordered and run is described in the overview.
REMOVE_CLASS
Takes a class away from every object that carries it, and drops the links the object stores under a key naming that class.
| Parameter | Type | Description |
|---|---|---|
class | QualifiedName | The class to remove. Required. |
when | condition | Optional. See when. |
{ "action": "REMOVE_CLASS", "class": "rulebooks.businessUnitMember" }
- Links go with it. Every link stored under a key that names the class, as
fromorto, is dropped, on objects without the class too. Move the links you want to keep first, with an earlier action in the same upgrade (see Relation actions). - Never the basic class. An object always keeps its basic class. Removing it from an object is refused: it is reported as an issue and the object is left as it was.
- The class may be gone from the model. Unlike other actions,
REMOVE_CLASSis not skipped when its ownclassis no longer in the tenant's model. That is the typical case. The platform only warns when the class is still in the model.
Why you need it
A class the model no longer references is no longer loaded. An object that still carries it, for example a role granted to a person through a relation, becomes unreadable: reading it returns 404. Removing a relation to a role, or reversing it, does not take the role off the objects that were linked.
Checklist: removing or reversing a relation to a role
When the model drops a relation to a role, or reverses it, and nothing references the role any more:
- Name the relation as stored. It is stored under the class that declares it, also when its target is a role. Check the declaring class in the old model.
- Reverse or move first. For a reversal onto the class that now declares the relation, give
becomeswhen the reversed pair is not where the new relation lives (see REVERSE_RELATION). Without it, the action is skipped for the tenant, as the role is no longer in the model. - Then remove the role with
REMOVE_CLASS, in the same upgrade, after the actions that still need the role's links. - Keep the order. If the role is removed before its links are moved, they are dropped with it.
Example
Business units used to list persons through the role rulebooks.businessUnitMember. Now a person picks its business units, declared on an EXTENSION of commons.person, and the role is gone from the model:
{
"version": 2,
"description": "Business units are chosen on the person; the member role is dropped",
"actions": [
{
"action": "REVERSE_RELATION",
"relation": { "from": "rulebooks.businessUnit", "to": "rulebooks.businessUnitMember" },
"multiple": true,
"becomes": { "from": "commons.person" }
},
{ "action": "REMOVE_CLASS", "class": "rulebooks.businessUnitMember" }
]
}
Order matters: the reversal reads the links under the role; only then the role and whatever is left under it can go.