Stage 2 · Lesson 9 of 10
Django ORM or SQLAlchemy with Alembic
comes with its own and system. Change a model, then run python manage.py makemigrations to generate a migration file, and migrate to apply it. With , the usual pair is for models and queries, and Alembic for migrations.
There, alembic revision --autogenerate drafts a script and alembic upgrade head applies it. Either way, commit the migration files and read what they will do. Use sqlmigrate, or Alembic's offline mode, to see the actual SQL.
Common trapa renamed field: Django asks whether you meant a rename, but Alembic autogenerate reads it as a dropped column plus a new one. Applied blindly, that deletes the data.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Relational Database Design and Modeling
Design Gurus · Intermediate · $98 one-time
The modelling and normalisation decisions that stay with a codebase for years
- CourseFreeCS50's Introduction to Databases with SQL
Harvard University · Beginner
Free course from querying through schema design, indexes, transactions and scaling
Practise
Also worth your time
- Database Indexing Explained: B-Tree, Hash, Bitmap, R-Tree, and When to Use Each (opens in a new tab)Read
B-tree and composite indexes, plus the leftmost-prefix rule that trips people up
What sits under your queries: storage engines, transactions and isolation levels