Database migration versioning#116
Open
gloskull wants to merge 2 commits into
Open
Conversation
…ioning Database migration versioning with resumable checkpoints and rollback support
Contributor
|
resolve conflicts @gloskull |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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****