test fix: must not infer delete field for deleted models
@@ -28,7 +28,7 @@ impl DataModelMigrationStepsInferrerImpl {
let models_to_create = self.models_to_create();
let models_to_delete = self.models_to_delete();
let fields_to_create = self.fields_to_create();
- let fields_to_delete = self.fields_to_delete();
+ let fields_to_delete = self.fields_to_delete(&models_to_delete);
let fields_to_update = self.fields_to_update();
result.append(&mut Self::wrap_as_step(models_to_create, MigrationStep::CreateModel));
@@ -97,9 +97,11 @@ impl DataModelMigrationStepsInferrerImpl {
result
}
- fn fields_to_delete(&self) -> Vec<DeleteField> {
+ fn fields_to_delete(&self, models_to_delete: &Vec<DeleteModel>) -> Vec<DeleteField> {
let mut result = Vec::new();
for previous_model in self.previous.models() {
+ let model_is_deleted = models_to_delete.iter().find(|dm| dm.name == previous_model.name).is_none();
+ if model_is_deleted {
for previous_field in previous_model.fields {
let must_delete_field = match self.next.find_model(previous_model.name.clone()) {
None => true,
@@ -114,6 +116,7 @@ impl DataModelMigrationStepsInferrerImpl {
}
}
}
+ }
result
}
