Update model file find method

This commit is contained in:
long2ice 2020-06-03 18:42:35 +08:00
parent b06da0223a
commit bf194ca8ce
2 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,10 @@ ChangeLog
0.1 0.1
=== ===
0.2.0
-----
- Update model file find method.
0.1.9 0.1.9
----- -----
- Fix default_connection when upgrade - Fix default_connection when upgrade

View File

@ -3,6 +3,7 @@ import os
import re import re
from copy import deepcopy from copy import deepcopy
from datetime import datetime from datetime import datetime
from importlib import import_module
from typing import Dict, List, Tuple, Type from typing import Dict, List, Tuple, Type
from tortoise import ( from tortoise import (
@ -195,7 +196,7 @@ class Migrate:
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 model != "aerich.models": if model != "aerich.models":
old_model_files.append(model.replace(".", "/") + ".py") old_model_files.append(import_module(model).__file__)
cls.cp_models(app, old_model_files, os.path.join(location, app, cls.get_old_model_file())) cls.cp_models(app, old_model_files, os.path.join(location, app, cls.get_old_model_file()))