0
0
Flaskframework~5 mins

Database migrations with Flask-Migrate - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of Flask-Migrate in a Flask application?
Flask-Migrate helps manage database schema changes over time by creating and applying migrations, so you can update your database structure without losing data.
Click to reveal answer
beginner
Which command initializes Flask-Migrate in your Flask project?
The command flask db init sets up the migration environment by creating a migrations folder to track changes.
Click to reveal answer
beginner
What does the command flask db migrate -m "message" do?
It creates a new migration script that records changes in your database models, with a message describing the update.
Click to reveal answer
beginner
How do you apply the migration scripts to update the database schema?
Use flask db upgrade to apply the latest migration scripts and update the database structure accordingly.
Click to reveal answer
intermediate
Why is it important to use migrations instead of manually changing the database?
Migrations keep track of changes safely, allow easy rollback, and help multiple developers stay in sync without losing data or causing errors.
Click to reveal answer
Which Flask-Migrate command creates the migration folder?
Aflask db init
Bflask db migrate
Cflask db upgrade
Dflask db create
What does flask db upgrade do?
ADeletes old migration files
BCreates a new migration script
CApplies migration scripts to update the database
DRolls back the last migration
When should you run flask db migrate?
AAfter changing your database models
BBefore initializing migrations
CTo apply migrations to the database
DTo delete migration history
Which file or folder does Flask-Migrate create to track migrations?
Amodels.py file
Bmigrate.py file
Cdb.sqlite file
Dmigrations folder
What is a key benefit of using Flask-Migrate in a team project?
AIt automatically writes your models
BIt helps keep database schema changes synchronized safely
CIt replaces the need for a database
DIt speeds up the Flask server
Explain the typical workflow for managing database changes using Flask-Migrate.
Think about the commands you run step-by-step after changing your models.
You got /4 concepts.
    Why is it better to use Flask-Migrate instead of manually editing the database schema?
    Consider safety and teamwork benefits.
    You got /4 concepts.