← Django learning pathDjango · Module 5 of 10
Migrations
Keep the database schema in sync with your models.
📖 Key ideas
- After changing models run python manage.py makemigrations.
- Apply them with python manage.py migrate.
- Migration files live in each app's migrations/ folder and go into Git.
- showmigrations lists applied migrations.
- Data migrations can transform existing rows.
💡 Real-life example: Migrations are renovation plans: each one records a change so every copy of the house is rebuilt the same way.
makemigrationsCreates migration files
migrateApplies migrations to the DB
Migration filePython file describing a schema change
Data migrationMigration that changes data