Making Flask Migrations

Learn how to make migrations in Flask.

Creating a migration file

We must create a migration file to make migrations in our Core app. Let’s create a migration file in the backendservice2 folder named manager.py. Then, we can open the file and import the following modules:

Press + to interact
from core import core
from core import db
from flask_migrate import Migrate
from flask_migrate import MigrateCommand
from flask_script import Manager
  • Lines 1–2: We import our Flask application instance, core, and our MySQL database instance, db, from our core.py.

  • Lines 3–4: We import Migrate and the MigrateCommand from flask_migrate.

  • Line 5: We import the Manager from flask_script.

Now that we are done with the imports ...