0Pricing
Django Academy · Lektion

makemigrations vs. migrate

Wie Django Schemaänderungen plant und anwendet.

makemigrations vs. migrate ist eine kostenlose Django Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Django Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Django Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Two Steps, Not One

Django changes your database in two steps: first it writes a plan, then it runs that plan. Knowing which is which saves a lot of confusion. 🧭

makemigrations Plans

makemigrations looks at your models, spots what changed, and writes a migration file describing the change. It does not touch the database yet.

python manage.py makemigrations

migrate Applies

migrate takes those migration files and actually runs them against the database, creating or altering real tables.

python manage.py migrate

Why Split Them

Splitting plan from action lets you review a change, commit it to git, and apply the exact same steps on every machine and server.

Migrations Are Files

Each plan lives as a file in your app under migrations/. You commit these files so teammates apply identical changes.

A Typical Cycle

Edit a model, run makemigrations to record it, then run migrate to apply it. That loop is your everyday schema workflow.

Naming Migrations

Add a clear label so files read like a history, not a pile of numbers. Use the --name flag to describe what changed.

python manage.py makemigrations --name add_published_field

Targeting One App

Pass an app label to generate or apply migrations for just that app, keeping unrelated changes out of the way.

python manage.py makemigrations blog

Check Without Changing

Run makemigrations with --check in CI to fail the build if a model change has no matching migration yet.

python manage.py makemigrations --check --dry-run

See What Is Applied

The showmigrations command lists every migration and marks the applied ones with an X, so you know your exact state.

python manage.py showmigrations

Order Matters

Always makemigrations first, then migrate. Running migrate alone applies whatever plans already exist, including Django built-ins.

Quick Check

Which command actually changes the database tables?

Recap

You learned the rhythm: makemigrations writes the plan, migrate applies it. Plan first, apply second, and your schema stays in sync everywhere. 🎉

Häufig gestellte Fragen

Ist die Lektion „makemigrations vs. migrate“ kostenlos?

Ja — der vollständige Text von „makemigrations vs. migrate“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Django Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Django Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „makemigrations vs. migrate“?

Wie Django Schemaänderungen plant und anwendet. Du übst Django Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Django Academy zu starten?

Keine Vorkenntnisse erforderlich. Django Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „makemigrations vs. migrate“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Django Academy-Lektion Code schreiben und ausführen?

Ja. Jede Django Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. makemigrations vs. migrate
  2. Eine Migrationsdatei lesen
  3. Ein Model ändern und erneut migrieren
  4. sqlmigrate und SQL untersuchen
← Zurück zu Django Academy