0
0
Flaskframework~10 mins

Database migrations with Flask-Migrate - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Flask-Migrate with the Flask app and SQLAlchemy database.

Flask
from flask_migrate import Migrate
migrate = Migrate(app, [1])
Drag options to blanks, or click blank then click option'
Amigrate
Bdb
Capp
DMigrate
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the Flask app twice instead of the database instance.
Using the wrong variable name for the database.
2fill in blank
medium

Complete the command to create a new migration script with Flask-Migrate.

Flask
flask db [1] -m "Initial migration"
Drag options to blanks, or click blank then click option'
Amigrate
Bdowngrade
Cinit
Dupgrade
Attempts:
3 left
💡 Hint
Common Mistakes
Using upgrade instead of migrate to create migration scripts.
Using init after the project is already initialized.
3fill in blank
hard

Fix the error in the command to apply migrations to the database.

Flask
flask db [1]
Drag options to blanks, or click blank then click option'
Aupgrade
Bmigrate
Cinit
Drevision
Attempts:
3 left
💡 Hint
Common Mistakes
Using migrate instead of upgrade to apply changes.
Using init after migrations are already set up.
4fill in blank
hard

Fill both blanks to import and initialize Flask-Migrate in your app factory function.

Flask
from flask_migrate import [1]

def create_app():
    app = Flask(__name__)
    db.init_app(app)
    [2] = [1](app, db)
    return app
Drag options to blanks, or click blank then click option'
AMigrate
Bmigrate
CMigrateApp
Dmigrate_app
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for the class import.
Using the same name for both class and instance.
5fill in blank
hard

Fill all three blanks to create a migration script and apply it in one sequence.

Flask
flask db [1] -m "Add user table"
flask db [2]
flask db [3]
Drag options to blanks, or click blank then click option'
Amigrate
Bupgrade
Cdowngrade
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using init in the middle of migration commands.
Mixing up upgrade and downgrade order.