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

def show_list(self, connection, app_names=None):

    loader = MigrationLoader(connection, ignore_no_migrations=True)
    graph = loader.graph
    if app_names:
        self._validate_app_names(loader, app_names)
    else:
        app_names = sorted(loader.migrated_apps)
    for app_name in app_names:
        self.stdout.write(app_name, self.style.MIGRATE_LABEL)
        shown = set()
        for node in graph.leaf_nodes(app_name):
            for plan_node in graph.forwards_plan(node):
                if ((plan_node not in shown) and (plan_node[0] == app_name)):
                    title = plan_node[1]
                    if graph.nodes[plan_node].replaces:
                        title += ('    (%s    squashed    migrations)' % len(graph.nodes[plan_node].replaces))
                    if (plan_node in loader.applied_migrations):
                        self.stdout.write(('    [X]    %s' % title))
                    else:
                        self.stdout.write(('    [    ]    %s' % title))
                    shown.add(plan_node)
        if (not shown):
            self.stdout.write('    (no    migrations)', self.style.ERROR)
