Performance: Migrations concept and workflow
This concept affects the backend database schema update speed and the initial page load time when migrations run during deployment.
Use zero-downtime migration strategies like adding nullable columns first, then backfilling data, and finally making columns non-nullable in separate deploys
python manage.py migrate --noinput during peak traffic without downtime strategy
| Pattern | Database Locks | Server Blocking | User Impact | Verdict |
|---|---|---|---|---|
| Run large migrations during peak traffic | Long locks on tables | Blocks server requests | Slow or failed page loads | [X] Bad |
| Apply small, incremental migrations with zero-downtime strategy | Minimal or no locks | Non-blocking server | Smooth user experience | [OK] Good |
makemigrations generates migration files based on model changes.migrate applies migrations, runserver starts the server, and collectstatic collects static files.python manage.py makemigrations
python manage.py migrate
python manage.py migrate but got an error saying a migration file is missing. What is the likely cause?makemigrations generates migration files needed before applying them with migrate.makemigrations to generate migration files reflecting the new field.migrate on each machine to update the database schema safely.Pass the test and this pattern moves unknown