diff --git a/mm2src/coins/nft/storage/wasm/wasm_storage.rs b/mm2src/coins/nft/storage/wasm/wasm_storage.rs index 524df5e3f0..c05395ada8 100644 --- a/mm2src/coins/nft/storage/wasm/wasm_storage.rs +++ b/mm2src/coins/nft/storage/wasm/wasm_storage.rs @@ -17,6 +17,7 @@ use num_traits::ToPrimitive; use serde_json::{self as json, Value as Json}; use std::collections::HashSet; use std::num::NonZeroUsize; +use web_sys::console; const CHAIN_TOKEN_ADD_TOKEN_ID_INDEX: &str = "chain_token_add_token_id_index"; const CHAIN_BLOCK_NUMBER_INDEX: &str = "chain_block_number_index"; @@ -1012,9 +1013,11 @@ impl TableSignature for NftTransferHistoryTable { table.create_multi_index(CHAIN_IMAGE_DOMAIN_INDEX, &["chain", "image_domain"], false)?; table.create_index("block_number", false)?; table.create_index("chain", false)?; - } else if old_version == 1 && new_version == 2 { + } else if new_version == 2 { // Migration from version 1 to version 2 + console::log_1(&"Migrating from version 1 to version 2.".into()); + // Step 1: Create a temporary table to hold data with the old schema let temp_table_name = format!("{}_temp", Self::TABLE_NAME); let temp_table = upgrader.create_table(&temp_table_name)?; @@ -1042,6 +1045,8 @@ impl TableSignature for NftTransferHistoryTable { // TODO copy data from old_store to temp_store copy_store_data_sync(&old_store.object_store, &temp_store.object_store)?; + console::log_1("Copied data from old store to temp store".into()); + // Step 3: Delete the old object store upgrader.delete_table(Self::TABLE_NAME)?; diff --git a/mm2src/mm2_db/src/indexed_db/drivers/upgrader.rs b/mm2src/mm2_db/src/indexed_db/drivers/upgrader.rs index feb4bbc9ca..b2bf2f65b3 100644 --- a/mm2src/mm2_db/src/indexed_db/drivers/upgrader.rs +++ b/mm2src/mm2_db/src/indexed_db/drivers/upgrader.rs @@ -238,8 +238,5 @@ pub fn copy_store_data_sync( // Prevent the closure from being dropped onsuccess_callback.forget(); - // Note: We cannot block the function here to wait for completion. - // The transaction will remain open until all requests are completed. - Ok(()) }