Skip to main content

Command

This class provides a command-line interface for displaying all available migrations within a project. It allows users to view migrations as a categorized list per application or as a sequential execution plan, with support for filtering by specific applications and databases. The class also provides detailed output regarding migration status, squashed migrations, and dependency relationships based on the specified verbosity level.

Attributes

AttributeTypeDescription
helpstring = "Shows all available migrations for the current project"Shows all available migrations for the current project

Methods


add_arguments()

@classmethod
def add_arguments(
parser: [CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser)
)

Configures the command-line argument parser with options for filtering by app, selecting a database, and choosing between list or plan output formats.

Parameters

NameTypeDescription
parser[CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser)The argument parser instance used to define CLI flags and positional arguments.

handle()

@classmethod
def handle(
*args: tuple,
**options: dict
)

Executes the command logic by determining the requested output format and delegating to either the list or plan visualization methods.

Parameters

NameTypeDescription
*argstupleVariable length argument list.
**optionsdictThe parsed command-line options including 'verbosity', 'database', and 'format'.

show_list()

@classmethod
def show_list(
connection: [BaseDatabaseWrapper](../../../../db/backends/base/base/basedatabasewrapper.md?sid=django_db_backends_base_base_basedatabasewrapper),
app_names: list = None
)

Show a list of all migrations on the system, or only those of some named apps.

Parameters

NameTypeDescription
connection[BaseDatabaseWrapper](../../../../db/backends/base/base/basedatabasewrapper.md?sid=django_db_backends_base_base_basedatabasewrapper)The database connection used to check the status of applied migrations.
app_nameslist = NoneAn optional list of app labels to filter the migration list output.

show_plan()

@classmethod
def show_plan(
connection: [BaseDatabaseWrapper](../../../../db/backends/base/base/basedatabasewrapper.md?sid=django_db_backends_base_base_basedatabasewrapper),
app_names: list = None
)

Show all known migrations (or only those of the specified app_names) in the order they will be applied.

Parameters

NameTypeDescription
connection[BaseDatabaseWrapper](../../../../db/backends/base/base/basedatabasewrapper.md?sid=django_db_backends_base_base_basedatabasewrapper)The database connection used to resolve the migration graph and application state.
app_nameslist = NoneAn optional list of app labels to restrict the migration plan to.