Merge pull request #328 from Fl0kse/fix_issue-150

try to fix "Add ManyToManyField will break migrate #150" issues
This commit is contained in:
long2ice 2024-01-23 22:08:08 +08:00 committed by GitHub
commit 51117867a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -258,6 +258,12 @@ class Migrate:
for action, option, change in diff(old_m2m_fields, new_m2m_fields):
if change[0][0] == "db_constraint":
continue
if isinstance(change[0][1], str):
for new_m2m_field in new_m2m_fields:
if new_m2m_field["name"] == change[0][1]:
table = new_m2m_field.get("through")
break
else:
table = change[0][1].get("through")
if action == "add":
add = False