use crate::{Config, Event, HasMigrationRun, NetworkImmunityPeriod, Pallet, Weight}; use scale_info::prelude::string::String; pub fn migrate_network_immunity_period() -> Weight { use frame_support::traits::Get; const NEW_VALUE: u64 = 864_000; let migration_name = b"migrate_network_immunity_period".to_vec(); let mut weight = T::DbWeight::get().reads(1); // Skip if already executed if HasMigrationRun::::get(&migration_name) { log::info!( target: "runtime", "Migration '{}' already run - skipping.", String::from_utf8_lossy(&migration_name) ); return weight; } // ── 1) Set new value ───────────────────────────────────────────────────── NetworkImmunityPeriod::::put(NEW_VALUE); weight = weight.saturating_add(T::DbWeight::get().writes(1)); Pallet::::deposit_event(Event::NetworkImmunityPeriodSet(NEW_VALUE)); // ── 2) Mark migration done ─────────────────────────────────────────────── HasMigrationRun::::insert(&migration_name, true); weight = weight.saturating_add(T::DbWeight::get().writes(1)); log::info!( target: "runtime", "Migration '{}' completed - NetworkImmunityPeriod => {}.", String::from_utf8_lossy(&migration_name), NEW_VALUE ); weight }