liveBook · Manning

Showmigrations

As explained in Django in Action

showmigrations is a Django management command that lists a project's migrations and indicates which ones have been applied.

showmigrations is a Django management command for checking migration state. It lists migrations across a project and marks applied migrations with an X, making database history easier to inspect than guesswork. section 10.4 section 10.6

Use the command to:

  • Display migration status for the entire project. section 10.6
  • Filter the listing by supplying one or more app names. section 10.4
  • Recognize squashed migrations and see how many migration scripts they combine. section 10.4

Inspect one app

Run `python manage.py showmigrations promoters`. The output lists each migration under `promoters`; `[X]` means it has run, while `[ ]` means it still needs to run. A squashed entry can also report its combined migration count. section 10.4

(venv) RiffMates$ python manage.py showmigrations promoters
promoters
 [X] 0001_initial
 [X] 0002_promoter_famous_for
 [X] 0003_promoter_common_name_promoter_full_name
 [X] 0004_data_fullname
 [X] 0005_remove_promoter_first_name_remove_promoter_last_name
 [ ] 0006_promoter_birth_squashed_0007_promoter_death (2 squashed migrations)

The listing makes applied, unapplied, and squashed migration states visible at a glance. section 10.4

How Django in Action covers it

How deep it goes
Shows detailed applied-state markers and squashed-script counts, but does not execute migrations.
Examples
Uses `python manage.py showmigrations promoters` to display applied, unapplied, and squashed migrations.
What you can do after
Diagnose migration state with Django's `showmigrations` command before deciding which migrations need attention.
How it connects
Connects migration status with Django migrations, squashed migrations, and the migrate management command.

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.