Challenge - 5 Problems
Migration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when you run
python manage.py migrate in production?You run
python manage.py migrate on a live Django app. What is the immediate effect on the database?Attempts:
2 left
💡 Hint
Think about what migrations are designed to do in Django.
✗ Incorrect
Running
python manage.py migrate applies all migrations that have not yet been applied to the database, updating the schema without deleting data.📝 Syntax
intermediate1:30remaining
Which command safely creates a new migration after model changes?
You changed a Django model in your app. Which command generates the migration file correctly?
Attempts:
2 left
💡 Hint
One command creates migration files, the other applies them.
✗ Incorrect
makemigrations creates migration files based on model changes. migrate applies them to the database.🔧 Debug
advanced2:30remaining
Why does this migration fail in production?
You added a non-nullable field without a default to a model and ran
makemigrations. Applying the migration in production fails. Why?Django
class MyModel(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() # new field, no default, not nullable
Attempts:
2 left
💡 Hint
Think about what happens when you add a required column to a table with existing data.
✗ Incorrect
Adding a non-nullable field without a default causes the database to reject the migration since existing rows have no value for that field.
🧠 Conceptual
advanced3:00remaining
What is the safest way to deploy a schema migration on a live Django app with heavy traffic?
You must add a new column to a large table without downtime. Which approach is safest?
Attempts:
2 left
💡 Hint
Think about how to avoid locking or errors on large tables.
✗ Incorrect
Adding a nullable column first avoids locking and errors. Then code can use it safely before making it required.
❓ state_output
expert3:00remaining
What is the state of the Django migration table after running
python manage.py migrate --fake appname 0003?You run
migrate --fake to mark migration 0003 as applied without running it. What does Django record in the migration history?Attempts:
2 left
💡 Hint
The --fake option marks migrations as done without running them.
✗ Incorrect
The --fake flag tells Django to record the migration as applied without executing its operations, useful for syncing state.