记flask-migrate无法跟踪到数据表的问题。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38125866/article/details/82749123
  • 初次进行migrate。不报错,但是表也没有创建。

在这里插入图片描述

  • 发现在shell中是要将模型类导进去才能建表。尝试在mange.py中也导入模型,成功解决问题。但是具体原因暂时不是很了解。
#_*_coding:utf-8_*_
'''
>author:classmate Lin

>email:[email protected] 

>create_time:2018.09.16

'''

from flask_script import Manager,Shell
from app.app import create_app
from flask_migrate import Migrate,MigrateCommand #flask 迁移数据


app = create_app()

'''
You must import the necessary tables here, otherwise you will not be able to track the tables.
'''
from app.models.user import User
from app.models.base import db

migrate = Migrate(app,db)
manager = Manager(app)

# Migration commands
manager.add_command('db', MigrateCommand)


if __name__ == '__main__':
    manager.run()

猜你喜欢

转载自blog.csdn.net/weixin_38125866/article/details/82749123