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進行數據庫遷移的基本步驟。您可以根據需要進行其他自定義配置和操作。