fix: fix migration process for database version 9#300
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR updates the database migration for version 9 by ensuring all residual Devnet/Regtest data is removed and enhances error clarity during contract registration/update.
- Added methods to purge asset lock transactions, contracts, identities, and tokens for Devnet/Regtest networks
- Invoked these purge methods in the version 9 migration path
- Replaced silent recreation on migration failure with a panic and refined error‐formatting in backend tasks
- Cleaned up duplicate UI module imports
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ui/tools/mod.rs | Removed duplicate contract_visualizer_screen module declaration |
| src/ui/tools/contract_visualizer_screen.rs | Reordered imports and condensed versioned_deserialize call |
| src/ui/mod.rs | Added and deduplicated ContractVisualizerScreen import |
| src/app.rs | Added and deduplicated ContractVisualizerScreen import |
| src/database/tokens.rs | Added delete_all_local_tokens_in_all_devnets_and_regtest |
| src/database/identities.rs | Added delete_all_identities_in_all_devnets_and_regtest |
| src/database/contracts.rs | Added remove_all_contracts_in_all_devnets_and_regtest |
| src/database/asset_lock_transaction.rs | Added remove_all_asset_locks_identity_id_for_all_devnets_and_regtest |
| src/database/initialization.rs | Switched to panic! on migration failure and wired in new deletes |
| src/backend_task/update_data_contract.rs | Reformatted error‐extraction and match arms |
| src/backend_task/register_contract.rs | Reformatted error‐extraction match arms and deduplicated import |
Comments suppressed due to low confidence (2)
src/database/contracts.rs:296
- [nitpick] The method name uses
remove_all...while similar modules usedelete_all.... Consider unifying the verb across database modules for consistency (e.g.,delete_all_contracts_in_all_devnets_and_regtest).
pub fn remove_all_contracts_in_all_devnets_and_regtest(&self) -> rusqlite::Result<()> {
src/database/tokens.rs:447
- There are no existing tests for this new deletion method. Adding unit tests to verify that
delete_all_local_tokens_in_all_devnets_and_regtestcorrectly removes Devnet/Regtest records would improve reliability.
pub fn delete_all_local_tokens_in_all_devnets_and_regtest(&self) -> rusqlite::Result<()> {
| self.create_tables()?; | ||
| self.set_default_version()?; | ||
| println!("Database reinitialized with default settings."); | ||
| panic!("Migration failed: {:?}", e); |
There was a problem hiding this comment.
Panicking on migration failure can cause abrupt application crashes. Consider handling failures gracefully—e.g., log the error, revert to a safe state, or retry—rather than using panic!.
Updated the migration process for database version 9 to ensure all relevant data is deleted from Devnet and Regtest networks. This includes:
This change is necessary to maintain data integrity and consistency during database migrations.