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 corefrom core import dbfrom flask_migrate import Migratefrom flask_migrate import MigrateCommandfrom flask_script import Manager
Lines 1–2: We import our Flask application instance,
core
, and our MySQL database instance,db
, from ourcore.py
.Lines 3–4: We import
Migrate
and theMigrateCommand
fromflask_migrate
.Line 5: We import the
Manager
fromflask_script
.
Now that we are done with the imports ...