How does Django's Migration system work, and why do we need both makemigrations and migrate?
Last updated
The migration system is Django's way of evolving the database schema in sync with your models, in versioned steps. It is two phases on purpose: makemigrations computes and records the changes as files, and migrate applies those files to the actual database.
makemigrations: author the change:Compares the current model state to the last migration's state and emits a new migration file containing operations like
AddFieldorCreateModel.Touches no database; it just produces code you can review and commit to version control.
migrate: apply the change:Runs unapplied migrations as SQL against the DB and records them in
django_migrations.Idempotent: already-applied migrations are skipped.
Why split them:
Separation of intent and execution: you generate and review changes on a dev machine, then apply the identical files across staging/production and every teammate's DB.
Lets migrations be portable artifacts (committed, diffed, edited as data migrations) rather than one-off live schema edits.
- https://meduzzen.com/blog/django-interview-questions/
- https://levelup.gitconnected.com/python-vs-go-for-backends-i-built-the-same-api-in-both-performance-shocked-me-8d57e6611577
- https://codefinity.com/blog/Top-50-Technical-Interview-Questions-for-Django-Developers
- https://www.geeksforgeeks.org/python/django-interview-questions/
- https://www.turing.com/interview-questions/django
- https://www.interviewbit.com/django-interview-questions/
- https://github.com/Devinterview-io/django-interview-questions
- https://foysalff.medium.com/12-advanced-django-interview-questions-for-experienced-developers-dbe654e21a45
- https://medium.com/@k0318383/django-vs-fastapi-which-framework-should-you-choose-for-your-backend-ab84cb8da33a
- https://digiqt.com/blog/django-interview-questions-for-employers/
- https://nareshit.com/blogs/django-flask-fastapi-which-to-learn-full-stack-python
- https://www.igmguru.com/blog/django-interview-questions
- https://medium.com/@tahakotwal54/django-vs-fastapi-which-one-should-you-choose-for-your-next-backend-project-50382c8c62c1
- https://blog.jetbrains.com/pycharm/2023/12/django-vs-fastapi-which-is-the-best-python-web-framework/
- https://www.youtube.com/watch?v=L5EPuiiQfY4