Bird
0
0

To safely add a new column to an existing table in a deployed Flask app's database, which sequence of commands should you run?

hard📝 Application Q8 of 15
Flask - Deployment
To safely add a new column to an existing table in a deployed Flask app's database, which sequence of commands should you run?
AModify model -> flask db migrate -> flask db upgrade
BModify model -> flask db upgrade -> flask db migrate
Cflask db migrate -> Modify model -> flask db upgrade
Dflask db upgrade -> Modify model -> flask db migrate
Step-by-Step Solution
Solution:
  1. Step 1: Modify the model

    Add the new column to your SQLAlchemy model in the Flask app code.
  2. Step 2: Generate migration script

    Run flask db migrate to create a migration script reflecting the model changes.
  3. Step 3: Apply migration

    Run flask db upgrade to apply the migration and update the database schema safely.
  4. Final Answer:

    Modify model -> flask db migrate -> flask db upgrade -> Option A
  5. Quick Check:

    Always migrate after model changes, then upgrade [OK]
Quick Trick: Modify model first, then migrate, then upgrade [OK]
Common Mistakes:
MISTAKES
  • Running upgrade before migrate
  • Migrating before modifying models
  • Skipping migration generation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes