@@ -135,63 +135,63 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
135135 let mut altered_fields: HashMap < String , Vec < ( & Field , & Field ) > > = HashMap :: new ( ) ;
136136
137137 // Check if any new models exist
138- internal_models. models . iter ( ) . for_each ( |x| {
138+ for x in & internal_models. models {
139139 if !old_lookup. iter ( ) . any ( |( a, _) | x. name == * a) {
140140 new_models. push ( x) ;
141141 }
142- } ) ;
142+ }
143143
144144 // Check if any old model got deleted
145- constructed. models . iter ( ) . for_each ( |x| {
145+ for x in & constructed. models {
146146 if !new_lookup. iter ( ) . any ( |( a, _) | x. name == * a) {
147147 deleted_models. push ( x) ;
148148 }
149- } ) ;
149+ }
150150
151151 // Iterate over all models, that are in the constructed
152152 // as well as in the new internal models
153- internal_models
154- . models
155- . iter ( )
156- . filter ( |x| old_lookup. contains_key ( x. name . as_str ( ) ) )
157- . for_each ( |x| {
158- // Check if a new field has been added
159- x. fields . iter ( ) . for_each ( |y| {
160- if !old_lookup[ x. name . as_str ( ) ]
161- . fields
162- . iter ( )
163- . any ( |z| z. name == y. name )
164- {
165- if !new_fields. contains_key ( x. name . as_str ( ) ) {
166- new_fields. insert ( x. name . clone ( ) , vec ! [ ] ) ;
167- }
168- new_fields. get_mut ( x. name . as_str ( ) ) . unwrap ( ) . push ( y) ;
153+ for x in & internal_models. models {
154+ if !old_lookup. contains_key ( x. name . as_str ( ) ) {
155+ continue ;
156+ }
157+
158+ // Check if a new field has been added
159+ for y in & x. fields {
160+ if !old_lookup[ x. name . as_str ( ) ]
161+ . fields
162+ . iter ( )
163+ . any ( |z| z. name == y. name )
164+ {
165+ if !new_fields. contains_key ( x. name . as_str ( ) ) {
166+ new_fields. insert ( x. name . clone ( ) , vec ! [ ] ) ;
169167 }
170- } ) ;
168+ new_fields. get_mut ( x. name . as_str ( ) ) . unwrap ( ) . push ( y) ;
169+ }
170+ }
171171
172- // Check if a existing field got deleted
173- old_lookup[ x. name . as_str ( ) ] . fields . iter ( ) . for_each ( |y| {
174- if !x. fields . iter ( ) . any ( |z| z. name == y. name ) {
175- if !deleted_fields. contains_key ( x. name . as_str ( ) ) {
176- deleted_fields. insert ( x. name . clone ( ) , vec ! [ ] ) ;
177- }
178- deleted_fields. get_mut ( x. name . as_str ( ) ) . unwrap ( ) . push ( y) ;
172+ // Check if a existing field got deleted
173+ for y in & old_lookup[ x. name . as_str ( ) ] . fields {
174+ if !x. fields . iter ( ) . any ( |z| z. name == y. name ) {
175+ if !deleted_fields. contains_key ( x. name . as_str ( ) ) {
176+ deleted_fields. insert ( x. name . clone ( ) , vec ! [ ] ) ;
179177 }
180- } ) ;
178+ deleted_fields. get_mut ( x. name . as_str ( ) ) . unwrap ( ) . push ( y) ;
179+ }
180+ }
181181
182- // Check if a existing field got altered
183- old_lookup[ x. name . as_str ( ) ] . fields . iter ( ) . for_each ( |y| {
184- x. fields . iter ( ) . filter ( |z| y. name == z. name ) . for_each ( |z| {
185- // Check for differences
186- if y. db_type != z. db_type || y. annotations != z. annotations {
187- if !altered_fields. contains_key ( x. name . as_str ( ) ) {
188- altered_fields. insert ( x. name . clone ( ) , vec ! [ ] ) ;
189- }
190- altered_fields. get_mut ( & x. name ) . unwrap ( ) . push ( ( y, z) ) ;
182+ // Check if a existing field got altered
183+ for y in & old_lookup[ x. name . as_str ( ) ] . fields {
184+ for z in & x. fields {
185+ // Check for differences
186+ if y. db_type != z. db_type || y. annotations != z. annotations {
187+ if !altered_fields. contains_key ( x. name . as_str ( ) ) {
188+ altered_fields. insert ( x. name . clone ( ) , vec ! [ ] ) ;
191189 }
192- } ) ;
193- } ) ;
194- } ) ;
190+ altered_fields. get_mut ( & x. name ) . unwrap ( ) . push ( ( y, z) ) ;
191+ }
192+ }
193+ }
194+ }
195195
196196 // Check if a model was renamed
197197 if !new_models. is_empty ( ) && !deleted_models. is_empty ( ) {
@@ -227,7 +227,7 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
227227 let mut references: HashMap < String , Vec < Field > > = HashMap :: new ( ) ;
228228
229229 // Create migration operations for new models
230- new_models . iter ( ) . for_each ( |x| {
230+ for x in & new_models {
231231 let mut normal_fields = vec ! [ ] ;
232232
233233 for y in & x. fields {
@@ -249,7 +249,7 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
249249 fields : normal_fields,
250250 } ) ;
251251 info ! ( "Created model {}" , x. name) ;
252- } ) ;
252+ }
253253
254254 // Create referencing fields for new models
255255 for ( model, fields) in references {
@@ -262,12 +262,12 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
262262 }
263263
264264 // Create migration operations for deleted models
265- deleted_models . iter ( ) . for_each ( |x| {
265+ for x in & deleted_models {
266266 op. push ( Operation :: DeleteModel {
267267 name : x. name . clone ( ) ,
268268 } ) ;
269269 info ! ( "Deleted model {}" , x. name) ;
270- } ) ;
270+ }
271271
272272 for ( model_name, new_fields) in & new_fields {
273273 if let Some ( old_fields) = deleted_fields. get ( model_name) {
@@ -298,7 +298,7 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
298298 }
299299 }
300300 // Remove renamed fields in existing models from new and deleted lists
301- renamed_fields . iter ( ) . for_each ( | ( model_name, fields) | {
301+ for ( model_name, fields) in & renamed_fields {
302302 for ( old_field, new_field) in fields {
303303 new_fields
304304 . get_mut ( model_name)
@@ -316,33 +316,33 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
316316 new : new_field. name . clone ( ) ,
317317 } )
318318 }
319- } ) ;
319+ }
320320
321321 // Create migration operations for new fields in existing models
322- new_fields . iter ( ) . for_each ( | ( x, y) | {
323- y . iter ( ) . for_each ( |z| {
322+ for ( x, y) in & new_fields {
323+ for z in y {
324324 op. push ( Operation :: CreateField {
325325 model : x. clone ( ) ,
326326 field : ( * z) . clone ( ) ,
327327 } ) ;
328328 info ! ( "Added field {} to model {}" , z. name, x) ;
329- } )
330- } ) ;
329+ }
330+ }
331331
332332 // Create migration operations for deleted fields in existing models
333- deleted_fields . iter ( ) . for_each ( | ( x, y) | {
334- y . iter ( ) . for_each ( |z| {
333+ for ( x, y) in & deleted_fields {
334+ for z in y {
335335 op. push ( Operation :: DeleteField {
336336 model : x. clone ( ) ,
337337 name : z. name . clone ( ) ,
338338 } ) ;
339339 info ! ( "Deleted field {} from model {}" , z. name, x) ;
340- } )
341- } ) ;
340+ }
341+ }
342342
343343 // Create migration operations for altered fields in existing models
344- altered_fields . iter ( ) . for_each ( | ( model, af) | {
345- af . iter ( ) . for_each ( | ( old, new) | {
344+ for ( model, af) in & altered_fields {
345+ for ( old, new) in af {
346346 // Check datatype
347347 if old. db_type != new. db_type {
348348 #[ expect( clippy:: match_single_binding, reason = "It will be extended™" ) ]
@@ -376,8 +376,8 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
376376 } ) ;
377377 info ! ( "Recreated field {} on model {}" , & new. name, & model) ;
378378 }
379- } ) ;
380- } ) ;
379+ }
380+ }
381381
382382 new_migration = Some ( Migration {
383383 hash : h. to_string ( ) ,
0 commit comments