#33586: Cannot delete object (A) referenced by another object (B) if said object
(A) has a foreign key to a custom user.
-------------------------------+------------------------------------
Reporter: Jeremy Poulin | Owner: Bhuvnesh
Type: Bug | Status: assigned
Component: Migrations | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Bhuvnesh):
Proposed solution: Loading apps while generating post migration state.
{{{#!diff
diff --git a/django/db/migrations/executor.py
b/django/db/migrations/executor.py
index eb738cf457..7f1f6bd1cc 100644
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -200,8 +200,6 @@ class MigrationExecutor:
# process.
break
if migration in migrations_to_run:
- if "apps" not in state.__dict__:
- state.apps # Render all -- performance critical
# The state before this migration
states[migration] = state
# The old state keeps as-is, we continue with the new
state
@@ -227,6 +225,8 @@ class MigrationExecutor:
for index, (migration, _) in enumerate(full_plan):
if migration == last_unapplied_migration:
for migration, _ in full_plan[index:]:
+ if "apps" not in state.__dict__:
+ state.apps # Render all -- performance critical
if migration in applied_migrations:
migration.mutate_state(state, preserve=False)
break
}}}
Ps: passing all tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/33586#comment:14>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701835746011c-31fdf825-a27f-4c92-b638-95107bb17207-000000%40eu-central-1.amazonses.com.