โ† 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