feat: Unified Migration System Design#1323
Open
quake wants to merge 20 commits intonervosnetwork:developfrom
Open
feat: Unified Migration System Design#1323quake wants to merge 20 commits intonervosnetwork:developfrom
quake wants to merge 20 commits intonervosnetwork:developfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a unified, callback-driven database migration flow in crates/fiber-store (usable across node/CLI and WASM), and archives the legacy standalone fnn-migrate tool for pre-INIT_DB_VERSION upgrades.
Changes:
- Refactors
fiber-storemigrations to run viaauto_migrate()with confirm/progress callbacks, and wires this into native (fiber-bin) and WASM (fiber-wasm) startup. - Archives the old
migrate/tool asmigrate_archive/and removes it from the Makefilechecktarget. - Updates migration-related tests and sample fixture version strings to align with the new migration epoch/versioning.
Reviewed changes
Copilot reviewed 21 out of 52 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| migrate_archive/src/util.rs | Legacy helper utilities for archived migrator (bincode convert + prompt). |
| migrate_archive/src/tests/sample_tests.rs | Archived tool tests for v0.7.0 sample round-trips and determinism. |
| migrate_archive/src/tests/mod.rs | Archived tool test module wiring. |
| migrate_archive/src/tests/migration_tests.rs | Archived tool tests validating v0.6.1→v0.7.0 migration behavior. |
| migrate_archive/src/migrations/sample.rs | Archived placeholder migration object example. |
| migrate_archive/src/migrations/mod.rs | Archived migration module registry list. |
| migrate_archive/src/migrations/mig_20260302_channel_replay_fields.rs | Archived migration appending new replay-related trailing fields. |
| migrate_archive/src/migrations/mig_20260302_channel_open_record.rs | Archived migration deleting ephemeral ChannelOpenRecord entries. |
| migrate_archive/src/migrations/mig_20260301_network_state_pubkey.rs | Archived migration clearing legacy network actor state entries. |
| migrate_archive/src/migrations/mig_20260204_pubkey_channel_index.rs | Archived migration rebuilding pubkey-based channel index. |
| migrate_archive/src/migrations/mig_20260203_trampoline.rs | Archived migration for trampoline-related schema changes (channel/payment/attempt). |
| migrate_archive/src/migrations/mig_20260203_channel_index.rs | Archived migration building channel→attempt index for non-final payments. |
| migrate_archive/src/migrations/mig_20251219.rs | Archived migration v0.6.0→v0.6.1 channel state conversion. |
| migrate_archive/src/migrations/mig_20250724.rs | Archived “breaking change” migration marker. |
| migrate_archive/src/migrations_backup/mig_20250617.rs | Archived backup migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250507.rs | Archived backup invoice migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250428.rs | Archived backup channel/payment migrations (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250407.rs | Archived backup broadcast-message cleanup migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250318.rs | Archived backup v0.4.0→v0.4.1 channel migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250308.rs | Archived backup timestamp key consolidation migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250307.rs | Archived backup payment-session migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250227.rs | Archived backup watchtower schema migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250123.rs | Archived backup v0.3.1→v0.4.0 channel migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250115.rs | Archived backup v0.2.1→v0.3.0 channel migration (historical reference). |
| migrate_archive/src/migrations_backup/mig_20250114.rs | Archived backup v0.2.0→v0.2.1 channel migration (historical reference). |
| migrate_archive/src/main.rs | Archived standalone migrator binary entrypoint. |
| migrate_archive/src/lib.rs | Archived migrator crate module exports. |
| migrate_archive/README.md | Documents that migrate_archive/ is reference-only and how to upgrade old DBs. |
| migrate_archive/Cargo.toml | Archived migrator crate manifest (not in workspace). |
| migrate_archive/build.rs | Archived build script generating migration registration code. |
| Makefile | Removes cd migrate && cargo check from the check target. |
| docs/plans/2026-04-09-unified-migration-system.md | Implementation plan for the unified migration system. |
| crates/fiber-wasm/src/lib.rs | Uses open_store_with_migration and adds WASM confirm/progress callbacks. |
| crates/fiber-types/src/sample/mod.rs | Updates fixture path examples to v0.8.0. |
| crates/fiber-types/src/sample/broadcast.rs | Updates sample broadcast message version string to 0.8.0. |
| crates/fiber-store/src/migrations/mod.rs | Adds migrations module with build-time registration include. |
| crates/fiber-store/src/migration.rs | Introduces callback-based auto-migration, new errors, and new INIT epoch. |
| crates/fiber-store/src/lib.rs | Exposes the new migrations module. |
| crates/fiber-store/src/db_migrate.rs | Simplifies DbMigrate to delegate to Migrations::auto_migrate(). |
| crates/fiber-store/Cargo.toml | Removes indicatif/console dependencies from fiber-store. |
| crates/fiber-store/build.rs | Updates build script to scan src/migrations and generate registration/latest version. |
| crates/fiber-lib/src/tests/test_utils.rs | Updates store opening call sites (formatting/compat with new API). |
| crates/fiber-lib/src/store/tests/store.rs | Updates store opening call sites (formatting/compat with new API). |
| crates/fiber-lib/src/store/tests/migrate.rs | Reworks migration tests for the new auto_migrate flow. |
| crates/fiber-lib/src/store/store_impl/mod.rs | Adds open_store_with_migration and wires unified auto-migrate into store open. |
| crates/fiber-lib/src/store/mod.rs | Re-exports open_store_with_migration and migration plan/progress types. |
| crates/fiber-lib/src/fiber/tests/gossip.rs | Updates store opening call sites (formatting/compat with new API). |
| crates/fiber-lib/src/build.rs | Removes build-time scanning of legacy migrate/ directory. |
| crates/fiber-lib/Cargo.toml | Removes no-longer-needed deps (e.g. indicatif/ouroboros). |
| crates/fiber-bin/src/main.rs | Wires CLI confirm/progress callbacks into store open at startup. |
| Cargo.lock | Updates lockfile to reflect dependency graph changes (plus additional version shifts). |
Member
Author
|
@copilot apply changes based on the comments in this thread |
quake
added a commit
to quake/fiber
that referenced
this pull request
May 5, 2026
- Fix stderr flush compile error in fiber-bin cli_confirm - Remove unused StorageBackend import in migration test - Include db version and migration guidance in check_validate messages
Zhangcy0x3
reviewed
May 6, 2026
Contributor
Zhangcy0x3
left a comment
There was a problem hiding this comment.
I've left a couple of technical suggestions regarding WASM error handling and some minor API improvements for BTreeMap. Please take a look when you have time.
chenyukang
reviewed
May 6, 2026
chenyukang
reviewed
May 7, 2026
Detailed plan covering 4 phases (12 tasks) for migrating from the standalone migrate/ crate to a unified migration system in fiber-store that works across all backends (RocksDB, SQLite, IndexedDB).
…catif/console deps
…stem - Fix fiber-bin/fiber-wasm imports to use fnn::store re-exports instead of direct fiber_store::migration (fiber-bin doesn't depend on fiber-store) - Add MigrationPlan/MigrationProgress re-exports in fiber-lib/src/store/mod.rs - Remove obsolete migration scanning code from fiber-lib/src/build.rs - Fix migration.rs auto_migrate() to use effective_latest_version() that considers dynamically registered migrations (fixes test failures) - Fix test_run_migration open_db call to pass &Path reference - Remove unused mut on DbMigrate variable in test
- Add open_store(path) that auto-confirms migration (for tests/simple setups) - Rename old 3-param version to open_store_with_migration (for CLI/WASM) - Fix all v0.7.x references to v0.8.x in migration messages, samples, docs
- Fix stderr flush compile error in fiber-bin cli_confirm - Remove unused StorageBackend import in migration test - Include db version and migration guidance in check_validate messages
- Use BTreeMap::range() instead of .iter().filter() for O(log n) lookup - Replace .expect() with .ok() in get_db_version to avoid WASM trap - Remove stale migrate/ references from release workflow - Introduce MigrationStore object-safe trait backed by StorageBackend to keep Migration dyn-compatible while avoiding concrete Store type
5f9ebc2 to
c9e0250
Compare
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.
Impl of #1256