What is the primary purpose of Flask-Migrate during the deployment of a Flask application?
Think about how your database structure changes when you update your code models.
Flask-Migrate helps manage database schema changes by generating migration scripts and applying them, ensuring the database matches the current models without data loss.
What happens when you run flask db migrate followed by flask db upgrade during deployment?
One command prepares changes, the other applies them.
flask db migrate creates migration scripts based on model changes. flask db upgrade applies those scripts to update the database schema.
You deployed a Flask app and ran migrations. Later, a teammate also created migrations on their branch. When merging, you get a conflict in migration scripts. What is the best way to resolve this?
Migration files are code and can be merged carefully.
Conflicts in migration scripts should be resolved by merging the files carefully to keep all schema changes, then applying the migrations.
After running flask db migrate and partially applying flask db upgrade, the deployment crashes. What is the likely state of the database?
Think about what happens if migration scripts are interrupted.
If the upgrade is interrupted, the database schema may be partially changed, leading to errors due to inconsistent structure.
Which option shows the correct way to add a new column age of type Integer to the users table in an Alembic migration script?
Remember to use the correct Alembic and SQLAlchemy syntax with proper imports.
The correct syntax uses op.add_column with sa.Column and sa.Integer(). Option D matches this exactly.