makemigrations frente a migrate
Cómo Django planifica y aplica cambios de esquema
makemigrations frente a migrate es una lección gratuita de Django Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Django Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Django Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en 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 makemigrationsmigrate Applies
migrate takes those migration files and actually runs them against the database, creating or altering real tables.
python manage.py migrateWhy 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_fieldTargeting 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 blogCheck 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-runSee 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 showmigrationsOrder 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. 🎉
Preguntas frecuentes
¿La lección «makemigrations frente a migrate» es gratis?
Sí — el texto completo de «makemigrations frente a migrate» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Django Academy, actualiza a CoddyKit PRO. El curso de Django Academy incluye 4 lecciones en total.
¿Qué aprenderé en «makemigrations frente a migrate»?
Cómo Django planifica y aplica cambios de esquema Practicas Django Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Django Academy?
No se requiere experiencia previa. Django Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.
¿Cuánto tiempo toma la lección «makemigrations frente a migrate»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Django Academy?
Sí. Cada lección de Django Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- makemigrations frente a migrate
- Leer un archivo de migración
- Cambiar un modelo y volver a migrar
- sqlmigrate e inspección de SQL