What is Flask-Migrate?
Answer
Flask-Migrate is a Flask extension that handles SQLAlchemy database schema migrations using Alembic. Without migrations, db.create_all() only creates new tables but does not modify existing ones — you cannot add columns or change types without dropping and recreating tables. Flask-Migrate tracks schema changes as migration scripts. Commands: flask db init (initialize migration folder). flask db migrate -m "Add phone column" (auto-generate migration from model changes). flask db upgrade (apply pending migrations). flask db downgrade (roll back last migration). Migration scripts are Python files stored in the migrations/ folder and should be committed to version control. Always review auto-generated migrations — Alembic may not detect all changes (e.g., column renames) and may generate incorrect migration SQL.
Previous
What is CORS and how do you enable it in Flask and FastAPI?
Next
What are FastAPI response models?