diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py index 97c94501c4..3b12909902 100644 --- a/django/core/management/commands/flush.py +++ b/django/core/management/commands/flush.py @@ -7,7 +7,7 @@ from django.apps import apps from django.core.management.base import BaseCommand, CommandError from django.core.management.color import no_style from django.core.management.sql import emit_post_migrate_signal, sql_flush -from django.db import DEFAULT_DB_ALIAS, connections, router, transaction +from django.db import DEFAULT_DB_ALIAS, connections, transaction from django.utils import six from django.utils.six.moves import input @@ -76,15 +76,8 @@ Are you sure you want to do this? six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2]) if not inhibit_post_migrate: - self.emit_post_migrate(verbosity, interactive, database) + # Emit the post migrate signal. This allows individual applications to + # respond as if the database had been migrated from scratch. + emit_post_migrate_signal(verbosity, interactive, database) else: self.stdout.write("Flush cancelled.\n") - - @staticmethod - def emit_post_migrate(verbosity, interactive, database): - # Emit the post migrate signal. This allows individual applications to - # respond as if the database had been migrated from scratch. - all_models = [] - for app_config in apps.get_app_configs(): - all_models.extend(router.get_migratable_models(app_config, database, include_auto_created=True)) - emit_post_migrate_signal(verbosity, interactive, database) diff --git a/django/test/testcases.py b/django/test/testcases.py index 853ac7b4d5..663760acd8 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -23,7 +23,7 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.handlers.wsgi import WSGIHandler, get_path_info from django.core.management import call_command from django.core.management.color import no_style -from django.core.management.commands import flush +from django.core.management.sql import emit_post_migrate_signal from django.core.servers.basehttp import WSGIRequestHandler, WSGIServer from django.core.urlresolvers import clear_url_caches, set_urlconf from django.db import DEFAULT_DB_ALIAS, connection, connections, transaction @@ -777,7 +777,7 @@ class TransactionTestCase(SimpleTestCase): value=self.available_apps, enter=True) for db_name in self._databases_names(include_mirrors=False): - flush.Command.emit_post_migrate(verbosity=0, interactive=False, database=db_name) + emit_post_migrate_signal(verbosity=0, interactive=False, db=db_name) try: self._fixture_setup() except Exception: