Browse Source

runtime: on runtime upgrade init content directory ids

Mokhtar Naamani 4 years ago
parent
commit
e46d0ba958
2 changed files with 7 additions and 3 deletions
  1. 1 1
      runtime-modules/content/src/lib.rs
  2. 6 2
      runtime/src/runtime_api.rs

+ 1 - 1
runtime-modules/content/src/lib.rs

@@ -355,7 +355,7 @@ impl<T: Trait> Module<T> {
 
 // Some initial config for the module on runtime upgrade
 impl<T: Trait> Module<T> {
-    pub fn set_initial_ids_to_one() {
+    pub fn on_runtime_upgrade() {
         <NextChannelCategoryId<T>>::put(T::ChannelCategoryId::one());
         <NextVideoCategoryId<T>>::put(T::VideoCategoryId::one());
         <NextVideoId<T>>::put(T::VideoId::one());

+ 6 - 2
runtime/src/runtime_api.rs

@@ -12,8 +12,8 @@ use sp_std::vec::Vec;
 
 use crate::constants::PRIMARY_PROBABILITY;
 use crate::{
-    AccountId, AuthorityDiscoveryId, Balance, BlockNumber, EpochDuration, GrandpaAuthorityList,
-    GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION,
+    content, AccountId, AuthorityDiscoveryId, Balance, BlockNumber, EpochDuration,
+    GrandpaAuthorityList, GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION,
 };
 use crate::{
     AllModules, AuthorityDiscovery, Babe, Call, Grandpa, Historical, InherentDataExt,
@@ -59,6 +59,10 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, Call, Signa
 pub struct CustomOnRuntimeUpgrade;
 impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
     fn on_runtime_upgrade() -> Weight {
+        content::Module::<Runtime>::on_runtime_upgrade();
+
+        // TODO: storage / data_directory migration or clear all data objects
+
         10_000_000 // TODO: adjust weight
     }
 }