Skip to content

Commit

Permalink
Fix Aerich b/c of Tortoise ORM v0.16.19
Browse files Browse the repository at this point in the history
  • Loading branch information
lqmanh committed Dec 26, 2020
1 parent 78a15f9 commit 47824a1
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 47824a1

Please sign in to comment.