0
0
Djangoframework~5 mins

Database migration in production in Django - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Apython manage.py makemigrations
Bpython manage.py migrate
Cpython manage.py runserver
Dpython manage.py collectstatic
What does python manage.py migrate do?
ACreates migration files
BApplies migrations to the database
CStarts the Django server
DDeletes old migrations
Why is it important to test migrations before running them in production?
ATo avoid syntax errors in Python code
BTo speed up the server
CTo update Django version
DTo prevent downtime or data loss
Which of these is a good practice for production migrations?
ABackup the database before migrating
BIgnore migration errors
CRun migrations during peak traffic
DSkip migrations to save time
What can cause downtime during a migration?
ARunning migrations on a test server
BUsing <code>makemigrations</code> command
CAdding new fields without default values
DWriting model comments
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.