0Pricing
Django Academy · Aula

makemigrations vs migrate

Como o Django planeja e aplica alterações de esquema

makemigrations vs migrate é uma aula grátis de Django Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Django Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Django Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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. 🎉

Perguntas Frequentes

A aula “makemigrations vs migrate” é grátis?

Sim — o texto completo de “makemigrations vs migrate” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Django Academy, atualize para CoddyKit PRO. O curso de Django Academy inclui 4 aulas no total.

O que vou aprender em “makemigrations vs migrate”?

Como o Django planeja e aplica alterações de esquema Você pratica Django Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Django Academy?

Nenhuma experiência prévia é necessária. Django Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “makemigrations vs migrate”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Django Academy?

Sim. Cada aula de Django Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. makemigrations vs migrate
  2. Lendo um Arquivo de Migração
  3. Alterando um Modelo e Migrando Novamente
  4. sqlmigrate e Inspeção de SQL
← Voltar para Django Academy