Skip to content

Commit cd176c1

Browse files
authored
Merge pull request #111 from lqmanh/bugfixes/fix-tortoise-orm-0.16.19
Fix Aerich b/c of a new feature in Tortoise ORM v0.16.19
2 parents c2819fc + 47824a1 commit cd176c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

aerich/migrate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from importlib import import_module
66
from io import StringIO
77
from pathlib import Path
8+
from types import ModuleType
89
from typing import Dict, List, Optional, Tuple, Type
910

1011
import click
@@ -210,7 +211,10 @@ def get_models_content(cls, config: dict, app: str, location: str):
210211
old_model_files = []
211212
models = config.get("apps").get(app).get("models")
212213
for model in models:
213-
module = import_module(model)
214+
if isinstance(model, ModuleType):
215+
module = model
216+
else:
217+
module = import_module(model)
214218
possible_models = [getattr(module, attr_name) for attr_name in dir(module)]
215219
for attr in filter(
216220
lambda x: inspect.isclass(x) and issubclass(x, Model) and x is not Model,

0 commit comments

Comments
 (0)