Reading a Migration File
Understand operations and dependencies inside.
Reading a Migration File is a free Django Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Django Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
It Is Just Python
A migration is an ordinary Python file you can open and read. Nothing magic lives inside, just a class describing changes.
The Migration Class
Every file defines a class named Migration that subclasses migrations.Migration. Django finds it by that name.
class Migration(migrations.Migration):
...Dependencies First
The dependencies list tells Django which migrations must run before this one, forming a clear order.
dependencies = [
("blog", "0001_initial"),
]The operations List
The heart of the file is operations, a list of steps Django runs in order to change your schema.
operations = [
migrations.AddField(...),
]CreateModel
The first migration usually holds a CreateModel operation, which builds a brand-new table from your model.
migrations.CreateModel(
name="Post",
fields=[...],
)AddField
AddField appears when you add a column to an existing model, naming the model, the field, and its type.
migrations.AddField(
model_name="post",
name="views",
field=models.IntegerField(default=0),
)Other Operations
You will also meet RemoveField, AlterField, and RenameField. Each maps to one clear change in the database.
initial = True
The first migration of an app sets initial to True. It marks the starting point of that app history.
initial = TrueNumbered Filenames
Files are numbered like 0001, 0002, and so on. The number plus the dependencies define the exact apply order.
Read, Do Not Hand-Edit
Read migrations to understand a change, but let Django generate them. Hand-editing is rare and easy to get wrong.
It Tells a Story
Reading files in order replays your schema history: each one is a small, reviewable chapter of how tables grew.
Quick Check
What does the dependencies list in a migration do?
Recap
A migration is plain Python: a Migration class with dependencies and an operations list. Now you can read any file and follow the change. 📖
Frequently asked questions
Is the “Reading a Migration File” lesson free?
Yes — the full text of “Reading a Migration File” is free to read here on the web, and the Django Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Django Academy course, upgrade to CoddyKit PRO.
What will I learn in “Reading a Migration File”?
Understand operations and dependencies inside. You practise Django Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Django Academy?
No prior experience is required. Django Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Reading a Migration File” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Django Academy lesson?
Yes. Every Django Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- makemigrations vs migrate
- Reading a Migration File
- Changing a Model and Re-migrating
- sqlmigrate and Inspecting SQL