- Version every client-side database schema/data change with a monotonic integer version.
- Keep critical migration orchestration under the 100ms P99 budget for normal paths; expensive backfills must run outside request/render paths.
- Provide deterministic rollback through
downmigrations and pre-migration snapshots. - Emit telemetry that can feed deployment gates, alerting, and dashboards.
| Layer | Responsibility |
|---|---|
| Migration definitions | Declare version, name, description, up, and down handlers. |
MigrationManager |
Sorts migrations, rejects duplicates, applies version ranges, captures rollback snapshots, records checksums/status, and emits telemetry. |
| Storage adapter | Persists records/snapshots to the relevant database or service metadata store. The core manager is storage-agnostic so services can use IndexedDB, SQL, or API-backed stores. |
| Observability | Ships migration_* telemetry events to monitoring and alerts on failures or SLO warnings. |
| Deployment gate | Blocks promotion when migration tests fail, security review is incomplete, or canary telemetry reports errors. |
- Before each
upmigration, capture a pre-migration snapshot. - If
upfails, restore the snapshot for that migration and stop the run. - For operator-triggered rollback, execute
downmigrations in descending version order until the target version is reached. - Keep the previous blue-green slot warm until canary analysis confirms the new migration version is healthy.
- Track migration duration, status, version, and checksum from
MigrationTelemetryEvent. - Page on any
migration_failedevent in production. - Warn on
migration_slo_warningwhen a migration exceeds the 100ms critical path budget. - Dashboard panels should include current version by service, failed migrations by release slot, P95/P99 duration, and rollback counts.
- Verify migrations do not log secrets or PII in errors/telemetry.
- Require checksum review for changed migration definitions.
- Confirm rollback snapshots inherit the same encryption/access controls as production data.
- Validate least-privilege database credentials for service-side adapters.