0
0
Djangoframework~5 mins

Migrations concept and workflow in Django - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a migration in Django?
A migration is a way Django tracks changes to your database schema. It helps update the database structure safely as your models change.
Click to reveal answer
beginner
What command do you use to create new migrations after changing models?
You use python manage.py makemigrations to create migration files that describe the changes in your models.
Click to reveal answer
beginner
What does the python manage.py migrate command do?
It applies the migration files to the database, updating the database schema to match your current models.
Click to reveal answer
intermediate
Why should you always review migration files before applying them?
Because migrations change your database, reviewing helps avoid mistakes like deleting data or wrong schema changes.
Click to reveal answer
beginner
What is the typical workflow when you change a Django model?
1. Change your model code.<br>2. Run python manage.py makemigrations to create migration files.<br>3. Review migration files.<br>4. Run python manage.py migrate to update the database.<br>5. Test your app to ensure it works.
Click to reveal answer
Which 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 the migrate command do?
ACreates new migration files
BUpdates the database schema based on migration files
CStarts the Django development server
DDeletes old migration files
Why is it important to review migration files before applying them?
ATo automatically fix errors in models
BTo speed up the migration process
CTo avoid accidental data loss or wrong schema changes
DTo generate documentation
What happens if you change a model but forget to run makemigrations?
AThe migration files will be deleted
BThe server will crash immediately
CDjango will auto-update the database
DThe database won't update to match the model changes
Which file type stores the instructions for database changes in Django migrations?
APython files (.py)
BJSON files (.json)
CSQL files (.sql)
DText files (.txt)
Explain the step-by-step workflow of making and applying migrations in Django.
Think about what happens after you change your models.
You got /5 concepts.
    Why are migrations important in Django projects? Describe their role and benefits.
    Consider how migrations help manage database changes over time.
    You got /5 concepts.