0PricingLogin
Flask Academy · Lesson

Init and Autogenerate a Migration

Run flask db init and migrate.

Install Flask-Migrate

First add the package to your project. Flask-Migrate brings Alembic and a set of handy flask db commands. 📦

pip install Flask-Migrate

Wire It to the App

Create a Migrate object and bind it to your app and db. That single line activates the whole flask db command group.

from flask_migrate import Migrate
migrate = Migrate(app, db)

All lessons in this course

  1. Why You Need Migrations, Not create_all
  2. Init and Autogenerate a Migration
  3. Apply and Roll Back with upgrade
  4. Review and Edit Generated Scripts
← Back to Flask Academy