@@ -117,6 +117,15 @@ impl Default for Options {
117117 }
118118}
119119
120+ impl From < & Options > for Partition {
121+ fn from ( value : & Options ) -> Self {
122+ Self {
123+ current : value. current ,
124+ total : value. total ,
125+ }
126+ }
127+ }
128+
120129pub trait DocumentProcessor {
121130 fn process < D > (
122131 & self ,
@@ -138,7 +147,7 @@ impl<'c> DocumentProcessor for SchemaManager<'c> {
138147 where
139148 D : Document ,
140149 {
141- let partition = Partition :: default ( ) ;
150+ let partition: Partition = options . into ( ) ;
142151 let db = self . get_connection ( ) ;
143152
144153 let tx = db. begin ( ) . await ?;
@@ -147,7 +156,7 @@ impl<'c> DocumentProcessor for SchemaManager<'c> {
147156
148157 stream:: iter (
149158 all. into_iter ( )
150- . filter ( |model| partition. is_selected :: < D > ( & model) ) ,
159+ . filter ( |model| partition. is_selected :: < D > ( model) ) ,
151160 )
152161 . map ( async |model| {
153162 let tx = db. begin ( ) . await ?;
@@ -207,6 +216,18 @@ pub struct Migrations {
207216 all : Vec < Migration > ,
208217}
209218
219+ impl Migrations {
220+ /// Return only [`Migration::Data`] migrations.
221+ pub fn only_data ( self ) -> Vec < Box < dyn MigrationTraitWithData > > {
222+ self . into_iter ( )
223+ . filter_map ( |migration| match migration {
224+ Migration :: Normal ( _) => None ,
225+ Migration :: Data ( migration) => Some ( migration) ,
226+ } )
227+ . collect ( )
228+ }
229+ }
230+
210231impl IntoIterator for Migrations {
211232 type Item = Migration ;
212233 type IntoIter = std:: vec:: IntoIter < Self :: Item > ;
0 commit comments