Bird
0
0

Given this Alembic command sequence:

medium📝 component behavior Q13 of 15
FastAPI - Database Integration
Given this Alembic command sequence:
alembic revision -m "add users table"
alembic upgrade head
What happens after running these commands?
AThe database schema is reset to the initial state
BThe migration script is deleted and no changes are applied
CA new migration script is created and the database schema is updated to include the users table
DThe database schema is downgraded by one version
Step-by-Step Solution
Solution:
  1. Step 1: Understand the revision command

    alembic revision -m "add users table" creates a new migration script file describing the addition of the users table.
  2. Step 2: Understand the upgrade command

    alembic upgrade head applies all migrations up to the latest, updating the database schema accordingly.
  3. Final Answer:

    A new migration script is created and the database schema is updated to include the users table -> Option C
  4. Quick Check:

    revision + upgrade = new migration applied [OK]
Quick Trick: Revision creates script; upgrade applies it to DB [OK]
Common Mistakes:
MISTAKES
  • Thinking upgrade resets or deletes migrations
  • Confusing downgrade with upgrade
  • Assuming revision applies changes immediately

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FastAPI Quizzes