Skip to content

Database migration versioning#116

Open
gloskull wants to merge 2 commits into
Utility-Protocol:mainfrom
gloskull:Database-Migration-Versioning
Open

Database migration versioning#116
gloskull wants to merge 2 commits into
Utility-Protocol:mainfrom
gloskull:Database-Migration-Versioning

Conversation

@gloskull

Copy link
Copy Markdown
Contributor

Motivation
Introduce a system-wide, resumable migration mechanism so storage schema upgrades can be executed in small batches and safely rolled back during canary/blue-green deployments.
Provide typed, queryable metadata and compact monitoring events to enable dashboards and alerting for migration progress and failures.
Ensure admin-controlled entrypoints for running, cancelling and (where supported) rolling back migrations to meet operational and safety requirements.
Description
Added persistent storage keys (StorageVersion, MigrationCursor, MigrationTarget, MigrationCheckpoint, MigrationRollback) and a new RollbackUnavailable contract error.
Added migration constants (MIGRATION_INSTRUCTION_BUDGET, CURRENT_STORAGE_VERSION, MIGRATION_BATCH_SIZE) and implemented typed MigrationCheckpoint and MigrationRollback contract types.
Implemented resumable v1→v2 migration logic with checkpointing, budget checks, MigBatch / MigDone events and automatic preparation of rollback metadata, plus a v2→v1 rollback implementation and MigRoll event.
Exposed admin/public entrypoints: rollback_migration, get_migration_checkpoint, get_migration_rollback, and integrated checkpoint-aware run_migration, cancel_migration, and observability (StrVer, MigBatch, MigDone, MigRoll, MigCancel); also added user-facing documentation DATABASE_MIGRATION_VERSIONING.md.
Small related fixes: shortened an event symbol to fit SDK limits and ensured BytesN values are cloned where reused in events.
Testing
Ran cargo fmt and git diff --check which completed successfully.
Executed the storage-versioning integration tests via cargo test --test storage_versioning_tests -- --nocapture, which failed to complete because the crate as a whole has preexisting compile errors in unrelated modules (e.g., tariff_oracle, ghost_sweeper, nonce_sync) that prevented the test binary from building.
The migration unit/integration flow added by this change is covered by the new test test_migration_checkpoint_and_rollback_metadata in contracts/utility_contracts/tests/storage_versioning_tests.rs, but running the test requires resolving the unrelated compile issues in the workspace first.
Closes #77****

gloskull added 2 commits July 17, 2026 17:25
…ioning

Database migration versioning with resumable checkpoints and rollback support
@JerryIdoko

Copy link
Copy Markdown
Contributor

resolve conflicts @gloskull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Database Migration Versioning with Rollback Support

2 participants