Making Flask Migrations
Learn how to make migrations in Flask.
We'll cover the following...
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:
Lines 1–2: We import our Flask application instance,
core, and our MySQL database instance,db, from ourcore.py.Lines 3–4: We import
Migrateand theMigrateCommandfromflask_migrate.Line 5: We import the
Managerfromflask_script.
Now that we are done with the imports necessary for our migration file to function correctly, we can handle migrations in the following way:
Line 1: We create an instance of
Migrate,migrate, passing our Flask application instancecoreand databasedbas arguments.Line 3: ...