一、下载

pip3 install -i https://pypi.douban.com/simple flask-migrate

注意:依赖 flask-script

二、使用

manage.py

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from 项目名称 import create_app
from 项目名称 import db

app = create_app()
manager = Manager(app)
migrate = Migrate()
migrate.init_app(app, db)
""" # 数据库迁移命名 python manage.py db init # 生成表 使用一次即可 python manage.py db migrate # makemirations python manage.py db upgrade # migrate """ manager.add_command('db', MigrateCommand) if __name__ == '__main__': # app.run() manager.run()