Skip to content

Commit

Permalink
try to fix "Add ManyToManyField will break migrate #150" issues
Browse files Browse the repository at this point in the history
  • Loading branch information
artem.ulchenko committed Jan 18, 2024
1 parent b63fbcc commit b25c767
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion aerich/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ def diff_models(cls, old_models: Dict[str, dict], new_models: Dict[str, dict], u
for action, option, change in diff(old_m2m_fields, new_m2m_fields):
if change[0][0] == "db_constraint":
continue
table = change[0][1].get("through")
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
if upgrade and table not in cls._upgrade_m2m:
Expand Down

0 comments on commit b25c767

Please sign in to comment.