Fix Aerich b/c of Tortoise ORM v0.16.19

This commit is contained in:
Lương Quang Mạnh 2020-12-26 10:31:10 +07:00
parent 78a15f9f19
commit 47824a100b

View File

@ -5,6 +5,7 @@ from datetime import datetime
from importlib import import_module from importlib import import_module
from io import StringIO from io import StringIO
from pathlib import Path from pathlib import Path
from types import ModuleType
from typing import Dict, List, Optional, Tuple, Type from typing import Dict, List, Optional, Tuple, Type
import click import click
@ -210,6 +211,9 @@ class Migrate:
old_model_files = [] old_model_files = []
models = config.get("apps").get(app).get("models") models = config.get("apps").get(app).get("models")
for model in models: for model in models:
if isinstance(model, ModuleType):
module = model
else:
module = import_module(model) module = import_module(model)
possible_models = [getattr(module, attr_name) for attr_name in dir(module)] possible_models = [getattr(module, attr_name) for attr_name in dir(module)]
for attr in filter( for attr in filter(