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-MigrateWire 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
- Why You Need Migrations, Not create_all
- Init and Autogenerate a Migration
- Apply and Roll Back with upgrade
- Review and Edit Generated Scripts