Skip to content

Commit f45a2b5

Browse files
authored
Fix pre upgrade schema (#1825)
# Goal The goal of this PR is to fix the pre migration issue that somehow got slipped into `main` branch. An example of the error is the following: ``` 2023-12-21 20:34:20 Running pre_upgrade... 2023-12-21 20:34:20 (key, value) failed to decode at [238, 198, 243, 193, 61, 38, 174, 37, 7, 201, 155, 103, 81, 225, 158, 118, 13, 72, 203, 53, 182, 108, 220, 238, 63, 151, 213, 0, 114, 204, 79, 216, 6, 164, 163, 214, 215, 161, 241, 20, 108, 0]: Error 2023-12-21 20:34:20 (key, value) failed to decode at [238, 198, 243, 193, 61, 38, 174, 37, 7, 201, 155, 103, 81, 225, 158, 118, 13, 72, 203, 53, 182, 108, 220, 238, 63, 151, 213, 0, 114, 204, 79, 216, 7, 99, 201, 131, 129, 220, 137, 171, 101, 0]: Error [More with other at values] ``` Related to #1693 # Discussion <!-- List discussion items --> # Checklist - [X] try-runtime was updated # verification The try-runtime works as expected ![Screenshot 2023-12-21 at 1 53 04 PM](https://github.com/LibertyDSNP/frequency/assets/9152501/48652d58-0a08-4133-bab3-4398fdbf999f)
1 parent 928f35d commit f45a2b5

File tree

1 file changed

+7
-1
lines changed
  • pallets/schemas/src/migration

1 file changed

+7
-1
lines changed

pallets/schemas/src/migration/v3.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn get_known_schemas() -> BTreeMap<SchemaId, Vec<u8>> {
4949
pub mod old {
5050
use super::*;
5151
use common_primitives::schema::{ModelType, PayloadLocation, SchemaSettings};
52+
use frame_support::storage_alias;
5253

5354
#[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)]
5455
/// A structure defining a Schema information (excluding the payload)
@@ -60,6 +61,11 @@ pub mod old {
6061
/// additional control settings for the schema
6162
pub settings: SchemaSettings,
6263
}
64+
65+
/// Old Storage for schema info struct data
66+
#[storage_alias]
67+
pub(crate) type SchemaInfos<T: Config> =
68+
StorageMap<Pallet<T>, Twox64Concat, SchemaId, OldSchemaInfo, OptionQuery>;
6369
}
6470

6571
/// migration to v3 implementation
@@ -73,7 +79,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV3<T> {
7379
#[cfg(feature = "try-runtime")]
7480
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
7581
log::info!(target: LOG_TARGET, "Running pre_upgrade...");
76-
let count = SchemaInfos::<T>::iter().count() as u32;
82+
let count = old::SchemaInfos::<T>::iter().count() as u32;
7783
log::info!(target: LOG_TARGET, "Finish pre_upgrade for {:?}", count);
7884
Ok(count.encode())
7985
}

0 commit comments

Comments
 (0)