diff options
| author | Tim Fiedler <tim@0x68.de> | 2018-11-26 22:26:40 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-11-30 09:57:43 -0500 |
| commit | b07273a0f710c0ed00ccbc1c555b4f1e5d6fc662 (patch) | |
| tree | 813c4a95d2cbcbeaa2e87e8538dfdb750cbd5e62 | |
| parent | 8a1a9194686881e32d0e3aed52d7f4150238530c (diff) | |
Fixed #29987 -- Detected unmanaged model deletions.
| -rw-r--r-- | django/db/migrations/autodetector.py | 4 | ||||
| -rw-r--r-- | tests/migrations/test_autodetector.py | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index fa63745b48..3d3eeb9230 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -722,10 +722,6 @@ class MigrationAutodetector: for app_label, model_name in all_deleted_models: model_state = self.from_state.models[app_label, model_name] model = self.old_apps.get_model(app_label, model_name) - if not model._meta.managed: - # Skip here, no need to handle fields for unmanaged models - continue - # Gather related fields related_fields = {} for field in model._meta.local_fields: diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index 7a6a990b12..b52852fb52 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -1662,6 +1662,11 @@ class AutodetectorTests(TestCase): self.assertOperationTypes(changes, 'testapp', 0, ["CreateModel"]) self.assertOperationAttributes(changes, 'testapp', 0, 0, name="AuthorUnmanaged", options={"managed": False}) + def test_unmanaged_delete(self): + changes = self.get_changes([self.author_empty, self.author_unmanaged], [self.author_empty]) + self.assertNumberMigrations(changes, 'testapp', 1) + self.assertOperationTypes(changes, 'testapp', 0, ['DeleteModel']) + def test_unmanaged_to_managed(self): # Now, we test turning an unmanaged model into a managed model changes = self.get_changes( |
