Recall & Review
beginner
What is Alembic used for in FastAPI projects?
Alembic helps manage database schema changes by creating and applying migrations. It keeps the database structure in sync with your code changes.
Click to reveal answer
beginner
What command initializes Alembic in your project?
The command
alembic init alembic creates the Alembic folder and configuration files needed to start migrations.Click to reveal answer
beginner
How do you create a new migration script with Alembic?
Use
alembic revision -m "message" to create a new migration file where you define schema changes.Click to reveal answer
beginner
What does the command
alembic upgrade head do?It applies all pending migrations to update the database schema to the latest version.
Click to reveal answer
intermediate
Why is it important to keep migration scripts under version control?
Migration scripts track database changes over time. Keeping them in version control helps teams share and apply consistent database updates safely.
Click to reveal answer
Which Alembic command creates the initial setup files?
✗ Incorrect
The
alembic init alembic command sets up the Alembic environment with necessary files.What does
alembic revision -m "add users table" do?✗ Incorrect
This command creates a new migration file where you can define schema changes.
How do you apply all migrations to update your database?
✗ Incorrect
The
alembic upgrade head command applies all migrations to bring the database to the latest version.Where do Alembic migration scripts live by default?
✗ Incorrect
Alembic stores migration scripts inside the
alembic/versions directory by default.Why should you not edit migration scripts after applying them to production?
✗ Incorrect
Changing applied migrations can cause the database to get out of sync and lead to errors.
Explain the steps to create and apply a new Alembic migration in a FastAPI project.
Think about setup, writing changes, and applying them.
You got /4 concepts.
Describe why Alembic migrations are important for managing database changes in web applications.
Consider teamwork and database consistency.
You got /4 concepts.