bcquality/microsoft/knowledge/upgrade/check-only-triggers-do-not-migrate-data.md
Jesper Schulz-Wedde 0c2a0ceb82 Add lifecycle error and privacy knowledge
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 95c06ad8-377d-4faa-8d07-06300b1c81ec
2026-07-14 12:02:49 +02:00

1.2 KiB

bc-version domain keywords technologies countries application-area
all
upgrade
on-check-preconditions
on-validate-upgrade
on-upgrade
read-only-check
data-migration
al
w1
all

Upgrade check triggers do not migrate data

Description

OnCheckPreconditionsPerCompany/PerDatabase run before the upgrade to verify that it can start. OnValidateUpgradePerCompany/PerDatabase run after upgrade logic to verify that it succeeded. Treat both phases as read-only checks. The OnUpgradePerCompany/PerDatabase phase is where the platform expects actual data transformation.

Best Practice

Have check triggers call query-only helpers that raise an error when an invariant fails. Put every Insert, Modify, Delete, Rename, DataTransfer, and other migration write behind helpers called from the matching OnUpgrade... trigger.

See sample: check-only-triggers-do-not-migrate-data.good.al.

Anti Pattern

Repairing data in OnCheckPreconditions... or finishing migration in OnValidateUpgrade.... Those writes blur the phase contract and make a check alter the state it is supposed to assess.

See sample: check-only-triggers-do-not-migrate-data.bad.al.