@@ -45,9 +45,11 @@ mod v0 {
45
45
#[ allow( dead_code) ]
46
46
pub ( crate ) mod v1 {
47
47
use super :: * ;
48
+
49
+
48
50
pub fn migrate_to_v1 < T : Config > ( weight : & mut Weight ) {
49
51
if v2:: StorageVersion :: < T > :: get ( ) == v2:: Release :: V0 {
50
- crate :: Briefs :: < T > :: translate ( |_, brief : v0:: BriefDataV0 < T > | {
52
+ v2 :: BriefsV2 :: < T > :: translate ( |_, brief : v0:: BriefDataV0 < T > | {
51
53
* weight += T :: DbWeight :: get ( ) . reads_writes ( 2 , 1 ) ;
52
54
let maybe_milestones: Result < BoundedProposedMilestones < T > , _ > = brief
53
55
. milestones
@@ -69,7 +71,7 @@ pub(crate) mod v1 {
69
71
if milestones. len ( ) != brief. milestones . len ( ) {
70
72
return None ;
71
73
}
72
- Some ( crate :: BriefData {
74
+ Some ( v2 :: BriefDataV2 {
73
75
brief_owners : brief. brief_owners ,
74
76
budget : brief. budget ,
75
77
currency_id : brief. currency_id ,
@@ -91,6 +93,24 @@ pub(crate) mod v1 {
91
93
pub mod v2 {
92
94
use super :: * ;
93
95
96
+ #[ storage_alias]
97
+ pub type BriefsV2 < T : Config > =
98
+ CountedStorageMap < Pallet < T > , Blake2_128Concat , BriefHash , BriefDataV2 < T > , OptionQuery > ;
99
+
100
+
101
+ #[ derive( Encode , Decode , PartialEq , Eq , Clone , Debug , MaxEncodedLen , TypeInfo ) ]
102
+ #[ scale_info( skip_type_params( T ) ) ]
103
+ pub struct BriefDataV2 < T : Config > {
104
+ pub brief_owners : BoundedBriefOwners < T > ,
105
+ pub budget : BalanceOf < T > ,
106
+ pub currency_id : CurrencyId ,
107
+ pub created_at : BlockNumberFor < T > ,
108
+ pub applicant : AccountIdOf < T > ,
109
+ pub milestones : BoundedProposedMilestones < T > ,
110
+ pub deposit_id : crate :: DepositIdOf < T > ,
111
+ }
112
+
113
+
94
114
#[ storage_alias]
95
115
pub type StorageVersion < T : Config > = StorageValue < Pallet < T > , Release , ValueQuery > ;
96
116
@@ -151,17 +171,17 @@ pub mod v3 {
151
171
use super :: * ;
152
172
153
173
pub struct MigrateToV3 < T : Config > ( T ) ;
154
- impl < T : Config > OnRuntimeUpgrade for MigrateToV2 < T > {
174
+ impl < T : Config > OnRuntimeUpgrade for MigrateToV3 < T > {
155
175
#[ cfg( feature = "try-runtime" ) ]
156
176
fn pre_upgrade ( ) -> Result < Vec < u8 > , TryRuntimeError > {
157
- let onchain = StorageVersion :: < T > :: on_chain_storage_version ( ) ;
158
- ensure ! ( onchain == 2 , "onchain must be version 2 to run the migration." )
177
+ let onchain = Pallet :: < T > :: on_chain_storage_version ( ) ;
178
+ ensure ! ( onchain == 2 , "onchain must be version 2 to run the migration." ) ;
159
179
Ok ( <Vec < u8 > as Default >:: default ( ) )
160
180
}
161
181
162
182
fn on_runtime_upgrade ( ) -> Weight {
163
183
let current = Pallet :: < T > :: current_storage_version ( ) ;
164
- let onchain = StorageVersion :: < T > :: on_chain_storage_version ( ) ;
184
+ let onchain = Pallet :: < T > :: on_chain_storage_version ( ) ;
165
185
let mut weight: Weight = Default :: default ( ) ;
166
186
if current == 3 && onchain == 2 {
167
187
@@ -177,9 +197,9 @@ pub mod v3 {
177
197
eoa : None ,
178
198
} ;
179
199
180
- T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 )
200
+ T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 ) ;
181
201
Briefs :: < T > :: insert ( key, migrated_brief) ;
182
- } )
202
+ } ) ;
183
203
184
204
current. put :: < Pallet < T > > ( ) ;
185
205
0 commit comments