mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Fixed #23337 -- Raised exception if squashed migration created circular dependency.
This commit is contained in:
parent
9543c605c3
commit
626afb6f13
@ -6,6 +6,7 @@ from django.conf import settings
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.core.management.utils import run_formatters
|
||||
from django.db import DEFAULT_DB_ALIAS, connections, migrations
|
||||
from django.db.migrations.exceptions import CircularDependencyError
|
||||
from django.db.migrations.loader import AmbiguityError, MigrationLoader
|
||||
from django.db.migrations.migration import SwappableTuple
|
||||
from django.db.migrations.optimizer import MigrationOptimizer
|
||||
@ -252,6 +253,14 @@ class Command(BaseCommand):
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
MigrationLoader(connections[DEFAULT_DB_ALIAS])
|
||||
except CircularDependencyError as e:
|
||||
os.remove(writer.path)
|
||||
raise CommandError(
|
||||
f"Squashed migration would create a circular dependency: {e}"
|
||||
)
|
||||
|
||||
def find_migration(self, loader, app_label, name):
|
||||
try:
|
||||
return loader.get_migration_by_prefix(app_label, name)
|
||||
|
Loading…
Reference in New Issue
Block a user