tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
843 stars 96 forks source link

数据迁移继承抽象类,无法迁移 #71

Closed lei7ma closed 4 years ago

lei7ma commented 4 years ago

这是我的抽象类 image 这个是我的配置 image 我的不同应用中model 继承抽象类就无法迁移,如果不继承就是可以的! image image

long2ice commented 4 years ago

抽象类是支持的,不确定是哪里的问题

lei7ma commented 4 years ago

图片这边我看不到,不知道你能看到吗, 问题就是,我的抽象类封在一个utils/model.py 里,我的项目目录像django哪样,每一个应用下都会有一个models去继承这个抽象类,迁移就会报错 File "/home/malei/.virtualenvs/sanic/lib/python3.7/site-packages/tortoise/init.py", line 355, in _discover_models raise ConfigurationError(f'Module "{models_path}" not found') tortoise.exceptions.ConfigurationError: Module "apps.users.models" not found 问题二: 只更新字段名, aerich migrate 生成的语句是{ "upgrade": [ "ALTER TABLE tb_user RENAME COLUMN email TO email2" ],}

long2ice commented 4 years ago

你可以试试debug到对应的那一行看为什么报错,然后问题二有什么问题吗,rename字段是会有一个确认操作

lei7ma commented 4 years ago

ALTER TABLE tb_user RENAME COLUMN email TO email2; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'COLUMN email TO email2' at line 1 是不是版本的问题啊

long2ice commented 4 years ago

是的,文档里写了,rename只支持MySQL8.0

lei7ma commented 4 years ago

好的谢谢