Challenge - 5 Problems
Flask-Migrate Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:00remaining
What is the primary purpose of Flask-Migrate?
Flask-Migrate is a tool used in Flask applications. What does it mainly help developers do?
Attempts:
2 left
💡 Hint
Think about how your database structure changes as your app grows.
✗ Incorrect
Flask-Migrate helps developers apply and track changes to the database schema safely using migration scripts.
❓ component_behavior
intermediate1:30remaining
What happens when you run 'flask db migrate'?
In a Flask app using Flask-Migrate, what does the command 'flask db migrate' do?
Attempts:
2 left
💡 Hint
This command prepares changes but does not apply them yet.
✗ Incorrect
'flask db migrate' generates a migration script reflecting model changes but does not update the database.
📝 Syntax
advanced2:00remaining
Identify the correct way to initialize Flask-Migrate
Given a Flask app and SQLAlchemy db instance, which code correctly initializes Flask-Migrate?
Flask
from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate app = Flask(__name__) db = SQLAlchemy(app) # Which line correctly initializes Migrate?
Attempts:
2 left
💡 Hint
Check the order of arguments in the Migrate constructor.
✗ Incorrect
Flask-Migrate requires the Flask app first, then the database instance to initialize properly.
❓ state_output
advanced1:30remaining
What is the state of the database after 'flask db upgrade'?
After running 'flask db upgrade' in a Flask app using Flask-Migrate, what is true about the database?
Attempts:
2 left
💡 Hint
This command applies all migrations that have not been applied yet.
✗ Incorrect
'flask db upgrade' applies all pending migrations so the database schema is up to date.
🔧 Debug
expert2:30remaining
Why does 'flask db migrate' fail with 'Target database is not up to date'?
You run 'flask db migrate' but get an error: 'Target database is not up to date'. What is the most likely cause?
Attempts:
2 left
💡 Hint
Think about the order of applying migrations before creating new ones.
✗ Incorrect
Flask-Migrate requires the database to be at the latest migration before creating new migration scripts.