Flask SQLAlchemy的迁移工具是Flask-Migrate,它使用Alembic来实现数据库迁移。以下是如何进行迁移的步骤:
pip install Flask-Migrate
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///mydatabase.db'
db = SQLAlchemy(app)
migrate = Migrate(app, db)
flask db init
flask db migrate -m "initial migration"
flask db upgrade
flask db downgrade
以上就是使用Flask-Migrate进行数据库迁移的基本步骤。您可以根据需要进行其他自定义配置和操作。