Skip to content

Commit

Permalink
Merge pull request #111 from lqmanh/bugfixes/fix-tortoise-orm-0.16.19
Browse files Browse the repository at this point in the history
Fix Aerich b/c of a new feature in Tortoise ORM v0.16.19
  • Loading branch information
long2ice authored Jan 4, 2021
2 parents c2819fc + 47824a1 commit cd176c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aerich/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from importlib import import_module
from io import StringIO
from pathlib import Path
from types import ModuleType
from typing import Dict, List, Optional, Tuple, Type

import click
Expand Down Expand Up @@ -210,7 +211,10 @@ def get_models_content(cls, config: dict, app: str, location: str):
old_model_files = []
models = config.get("apps").get(app).get("models")
for model in models:
module = import_module(model)
if isinstance(model, ModuleType):
module = model
else:
module = import_module(model)
possible_models = [getattr(module, attr_name) for attr_name in dir(module)]
for attr in filter(
lambda x: inspect.isclass(x) and issubclass(x, Model) and x is not Model,
Expand Down

0 comments on commit cd176c1

Please sign in to comment.