0
0
FastAPIframework~10 mins

Alembic migrations in FastAPI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new Alembic migration revision.

FastAPI
alembic [1] -m "add new table"
Drag options to blanks, or click blank then click option'
Arevision
Bupgrade
Cdowngrade
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upgrade' instead of 'revision' to create migration.
2fill in blank
medium

Complete the code to apply all pending Alembic migrations to the database.

FastAPI
alembic [1] head
Drag options to blanks, or click blank then click option'
Adowngrade
Brevision
Cupgrade
Dcurrent
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'revision' instead of 'upgrade' to apply migrations.
3fill in blank
hard

Fix the error in the Alembic command to revert the last migration.

FastAPI
alembic [1] -1
Drag options to blanks, or click blank then click option'
Adowngrade
Brevision
Cupgrade
Dhistory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upgrade' instead of 'downgrade' to revert migrations.
4fill in blank
hard

Fill both blanks to generate an Alembic migration that autogenerates changes and names it.

FastAPI
alembic [1] -m "[2]" --autogenerate
Drag options to blanks, or click blank then click option'
Arevision
Bupgrade
Cdowngrade
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upgrade' instead of 'revision' to create migration.
5fill in blank
hard

Fill all three blanks to write a Python Alembic migration script that adds a new column.

FastAPI
def upgrade():
    op.add_column('[1]', sa.Column('[2]', sa.String(), nullable=[3]))
Drag options to blanks, or click blank then click option'
Ausers
Bemail
CFalse
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting nullable to True when the column should not allow nulls.