DEV.co
Open-Source Databases · miguelgrinberg

Flask-Migrate

Flask-Migrate is a Python extension that automates database schema changes for Flask applications using SQLAlchemy and Alembic. It provides CLI commands (`flask db`) to initialize, generate, and apply database migrations without manual SQL.

Source: GitHub — github.com/miguelgrinberg/Flask-Migrate
2.4k
GitHub stars
234
Forks
Python
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorymiguelgrinberg/Flask-Migrate
Ownermiguelgrinberg
Primary languagePython
LicenseMIT — OSI-approved
Stars2.4k
Forks234
Open issues1
Latest releasev4.1.0 (2025-01-10)
Last updated2026-05-14
Sourcehttps://github.com/miguelgrinberg/Flask-Migrate

What Flask-Migrate is

Flask-Migrate wraps Alembic to provide Flask-integrated database migration management. It generates migration scripts from SQLAlchemy ORM model changes and applies them via `flask db migrate` and `flask db upgrade` commands, requiring manual review of generated scripts (Alembic cannot detect all schema changes, notably indexes).

Quickstart

Get the Flask-Migrate source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/miguelgrinberg/Flask-Migrate.gitcd Flask-Migrate# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Flask API & Web App Schema Evolution

Manage incremental database schema changes across development, staging, and production environments in Flask-based REST APIs and web applications with version-controlled migration scripts.

Team Collaboration on Schema Changes

Coordinate schema modifications across distributed teams by storing migration files in version control, enabling predictable, reviewable rollout of database structure changes.

Rapid Prototyping with Model-Driven Migrations

Accelerate development cycles by automatically generating migration scripts from SQLAlchemy ORM model definitions, reducing manual SQL authoring during early-stage schema iteration.

Implementation considerations

  • Generated migration scripts must be manually reviewed and edited before application; Alembic cannot automatically detect indexes, constraints, or certain column attribute changes.
  • Requires `FLASK_APP` environment variable to be set; migration folder and scripts must be version-controlled and deployed with application code.
  • Supports SQLite, PostgreSQL, MySQL, and other SQLAlchemy-supported databases; dialect-specific SQL may need manual adjustment in migration scripts.
  • Backward compatibility and rollback testing are critical; each migration should be reversible and tested in isolation before production deployment.
  • Database downtime during migration depends on schema change complexity; large ALTER TABLE operations may lock tables or require application downtime.

When to avoid it — and what to weigh

  • Complex Schema Logic Beyond ORM Detection — Avoid if migrations require database-specific features (triggers, stored procedures, check constraints) or if Alembic's auto-detection gaps (indexes, comment changes) cause friction without substantial manual script editing.
  • Non-Flask or Non-SQLAlchemy Stacks — Not applicable for applications using ORMs other than SQLAlchemy (e.g., Django ORM, Tortoise ORM) or non-Flask frameworks without substantial integration effort.
  • Microservices with Many Independent Databases — May introduce operational complexity if managing migrations across dozens of microservices with separate databases; consider centralized migration tooling or database versioning strategies instead.
  • Zero-Downtime Migration Constraints — Flask-Migrate does not inherently address zero-downtime deployment patterns; large schema changes may require custom migration strategies and coordination with application deployment pipelines.

License & commercial use

MIT License. Permissive OSI license permitting use, modification, and distribution in proprietary and open-source contexts with minimal restrictions; includes warranty disclaimer.

MIT license permits commercial use, modification, and private deployment without royalties or attribution requirements. However, consult internal compliance policies for any organizational restrictions on third-party Python dependencies.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

No security vulnerabilities reported in available data. Migrations execute with database user credentials; ensure database connection strings and credentials are managed securely (environment variables, secrets management). Generated migration scripts should be reviewed to prevent unintended SQL injection or privilege escalation. Alembic auto-detection may not catch all schema changes; manual review mitigates risk of undetected schema drift.

Alternatives to consider

Alembic (standalone)

Direct Alembic integration without Flask wrapper; choose if non-Flask framework is used or more control over migration workflow is desired.

Django Migrations (django.db.migrations)

Built-in migration tool for Django ORM; preferred if application uses Django framework instead of Flask/SQLAlchemy.

Flyway or Liquibase

Database-agnostic, language-agnostic migration tools with support for SQL-based and XML-based migrations; suit polyglot environments or complex schema logic outside ORM scope.

Software development agency

Build on Flask-Migrate with DEV.co software developers

Flask-Migrate simplifies schema management for Flask + SQLAlchemy applications. Evaluate fit with your stack, test in development, and integrate into your CI/CD pipeline. Our team can help integrate migrations into your deployment strategy.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

Flask-Migrate FAQ

Does Flask-Migrate detect all database schema changes automatically?
No. Alembic's auto-detection covers basic model changes (columns, types, constraints) but cannot detect indexes, column comments, database-specific features, or some constraint modifications. Manual script review and editing is required.
Can I use Flask-Migrate with databases other than SQLite?
Yes. Flask-Migrate supports any database supported by SQLAlchemy (PostgreSQL, MySQL, Oracle, SQL Server, etc.). Database-specific SQL in migration scripts may need adjustment.
How do I rollback a migration in production?
Use `flask db downgrade` to apply the previous migration version. Ensure migrations are reversible and tested in lower environments first. Downgrade operations depend on the migration script's `downgrade()` function being correctly implemented.
Is Flask-Migrate suitable for microservices architectures?
Flask-Migrate works per-application and database. In microservices, manage migrations per service; if many databases share schema, consider centralized migration tooling or database versioning strategies.

Software developers & web developers for hire

Need help beyond evaluating Flask-Migrate? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source databases integrations — and maintain them long-term.

Ready to Streamline Your Flask Database Migrations?

Flask-Migrate simplifies schema management for Flask + SQLAlchemy applications. Evaluate fit with your stack, test in development, and integrate into your CI/CD pipeline. Our team can help integrate migrations into your deployment strategy.