0
0
Djangoframework~5 mins

makemigrations and migrate commands in Django - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the makemigrations command do in Django?
It creates new migration files by detecting changes in your models. These files describe how to update the database schema.
Click to reveal answer
beginner
What is the purpose of the migrate command in Django?
It applies the migration files to the database, updating the database schema to match your models.
Click to reveal answer
beginner
Why do you need to run makemigrations before migrate?
Because makemigrations creates the instructions for database changes, and migrate actually applies those changes to the database.
Click to reveal answer
beginner
If you add a new field to a Django model, what commands should you run to update the database?
First run python manage.py makemigrations to create migration files, then run python manage.py migrate to apply changes to the database.
Click to reveal answer
intermediate
What happens if you run migrate without running makemigrations after changing models?
No new migration files exist, so the database won't update. Your changes won't be applied until you create migrations first.
Click to reveal answer
Which command creates migration files in Django?
Arunserver
Bmigrate
Cmakemigrations
Dstartapp
What does the migrate command do?
ADeletes migration files
BCreates migration files
CStarts the Django server
DApplies migrations to the database
If you change a model but forget to run makemigrations, what happens when you run migrate?
ANo changes are applied
BDatabase updates correctly
CDjango crashes
DMigration files are created automatically
Which command should you run first after changing models?
Amigrate
Bmakemigrations
Crunserver
Dcollectstatic
What is the main reason Django uses migrations?
ATo keep the database schema in sync with models
BTo speed up the server
CTo create HTML pages
DTo manage user sessions
Explain the roles of makemigrations and migrate commands in Django.
Think about how code changes become database changes.
You got /4 concepts.
    Describe the steps you take after adding a new field to a Django model to update the database.
    Focus on the order of commands and their purpose.
    You got /4 concepts.