Skip to content

Commit

Permalink
Fix bug for field change. (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
long2ice committed Mar 3, 2021
1 parent 49897dc commit 5215127
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 92 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### 0.5.1

- Fix tortoise connections not being closed properly. (#120)
- Fix bug for field change. (#119)

### 0.5.0

Expand Down
16 changes: 9 additions & 7 deletions aerich/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ def diff_models(cls, old_models: Dict[str, dict], new_models: Dict[str, dict], u
and cls._db_version.startswith("5.")
):
cls._add_operator(
cls._change_field(
model, new_data_field, old_data_field
),
cls._modify_field(model, new_data_field),
upgrade,
)
else:
Expand Down Expand Up @@ -376,13 +374,17 @@ def diff_models(cls, old_models: Dict[str, dict], new_models: Dict[str, dict], u
upgrade,
)
elif option == "db_field_types.":
# change column
# continue since repeated with others
continue
elif option == "default":
# change column default
cls._add_operator(cls._alter_default(model, new_data_field), upgrade)
else:
# modify column
cls._add_operator(
cls._change_field(model, old_data_field, new_data_field),
cls._modify_field(model, new_data_field),
upgrade,
)
elif option == "default":
cls._add_operator(cls._alter_default(model, new_data_field), upgrade)

for old_model in old_models:
if old_model not in new_models.keys():
Expand Down
124 changes: 59 additions & 65 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5215127

Please sign in to comment.