Recall & Review
beginner
What is a database migration in Django?
A database migration in Django is a way to update the database schema to match changes in your models. It helps keep the database structure in sync with your code without losing data.
Click to reveal answer
beginner
Why should you be careful when running migrations in production?
Because migrations can change the database structure, running them in production can cause downtime or data loss if not done carefully. It's important to plan and test migrations to avoid breaking the live app.
Click to reveal answer
beginner
What command do you use to create migrations in Django?
You use
python manage.py makemigrations to create migration files based on model changes.Click to reveal answer
beginner
How do you apply migrations to the production database?
You run
python manage.py migrate on the production server to apply all pending migrations safely.Click to reveal answer
intermediate
What is a common strategy to avoid downtime during production migrations?
A common strategy is to use zero-downtime deployment techniques, like running migrations in steps, using database locks carefully, or applying non-blocking migrations during low traffic times.
Click to reveal answer
Which Django command creates migration files after model changes?
✗ Incorrect
The command
makemigrations creates migration files based on model changes.What does
python manage.py migrate do?✗ Incorrect
The
migrate command applies all pending migrations to the database.Why is it important to test migrations before running them in production?
✗ Incorrect
Testing migrations helps prevent downtime or data loss in the live environment.
Which of these is a good practice for production migrations?
✗ Incorrect
Backing up the database before migrating protects data if something goes wrong.
What can cause downtime during a migration?
✗ Incorrect
Adding new fields without defaults can lock tables and cause downtime.
Explain the steps to safely perform a database migration in a Django production environment.
Think about preparation, testing, backup, and applying changes carefully.
You got /5 concepts.
Describe common challenges you might face when running migrations in production and how to handle them.
Consider risks and strategies to minimize impact.
You got /5 concepts.