File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
220220 } )
221221 }
222222
223- let mut references: HashMap < String , Field > = HashMap :: new ( ) ;
223+ let mut references: HashMap < String , Vec < Field > > = HashMap :: new ( ) ;
224224
225225 // Create migration operations for new models
226226 new_models. iter ( ) . for_each ( |x| {
@@ -231,7 +231,10 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
231231 . iter ( )
232232 . any ( |z| z. eq_shallow ( & Annotation :: ForeignKey ( Default :: default ( ) ) ) )
233233 {
234- references. insert ( x. name . clone ( ) , y. clone ( ) ) ;
234+ references
235+ . entry ( x. name . clone ( ) )
236+ . or_default ( )
237+ . push ( y. clone ( ) ) ;
235238 } else {
236239 normal_fields. push ( y. clone ( ) ) ;
237240 }
@@ -245,8 +248,13 @@ pub fn run_make_migrations(options: MakeMigrationsOptions) -> anyhow::Result<()>
245248 } ) ;
246249
247250 // Create referencing fields for new models
248- for ( model, field) in references {
249- op. push ( Operation :: CreateField { model, field } ) ;
251+ for ( model, fields) in references {
252+ for field in fields {
253+ op. push ( Operation :: CreateField {
254+ model : model. clone ( ) ,
255+ field,
256+ } ) ;
257+ }
250258 }
251259
252260 // Create migration operations for deleted models
You can’t perform that action at this time.
0 commit comments