Fixed #23975 -- Restored pre_migrate signal if all apps have migrations.

Thanks kmmbvnr for the report.
This commit is contained in:
Tim Graham 2014-12-09 08:43:40 -05:00
parent f91d7366e0
commit d2ff8a7241
4 changed files with 24 additions and 1 deletions

View File

@ -156,6 +156,7 @@ class Command(BaseCommand):
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
else:
created_models = []
emit_pre_migrate_signal([], self.verbosity, self.interactive, connection.alias)
# The test runner requires us to flush after a syncdb but before migrations,
# so do that here.

View File

@ -146,3 +146,6 @@ Bugfixes
* Fixed migration crash when adding ``order_with_respect_to`` to a table
with existing rows (:ticket:`23983`).
* Restored the ``pre_migrate`` signal if all apps have migrations
(:ticket:`23975`).

View File

@ -1,7 +1,7 @@
from django.apps import apps
from django.core import management
from django.db.models import signals
from django.test import TestCase
from django.test import override_settings, TestCase
from django.utils import six
@ -75,3 +75,22 @@ class MigrateSignalTests(TestCase):
self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
self.assertEqual(args['using'], 'default')
@override_settings(MIGRATION_MODULES={'migrate_signals': 'migrate_signals.custom_migrations'})
def test_pre_migrate_migrations_only(self):
"""
If all apps have migrations, pre_migrate should be sent.
"""
r = PreMigrateReceiver()
signals.pre_migrate.connect(r, sender=APP_CONFIG)
stdout = six.StringIO()
management.call_command('migrate', database=MIGRATE_DATABASE,
verbosity=MIGRATE_VERBOSITY, interactive=MIGRATE_INTERACTIVE,
load_initial_data=False, stdout=stdout)
args = r.call_args
self.assertEqual(r.call_counter, 1)
self.assertEqual(set(args), set(PRE_MIGRATE_ARGS))
self.assertEqual(args['app_config'], APP_CONFIG)
self.assertEqual(args['verbosity'], MIGRATE_VERBOSITY)
self.assertEqual(args['interactive'], MIGRATE_INTERACTIVE)
self.assertEqual(args['using'], 'default')