← Django learning path
Django · Module 5 of 10

Migrations

Keep the database schema in sync with your models.

📖 Key ideas

  1. After changing models run python manage.py makemigrations.
  2. Apply them with python manage.py migrate.
  3. Migration files live in each app's migrations/ folder and go into Git.
  4. showmigrations lists applied migrations.
  5. 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