From ad25fe73506d80ffcaac135ad0a8d09552b70d70 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 18 Aug 2016 18:17:01 -0400 Subject: [PATCH] Fixed #27089 -- Added database alias to InconsistentMigrationHistory message. --- django/db/migrations/loader.py | 4 +++- docs/releases/1.10.1.txt | 3 +++ tests/migrations/test_loader.py | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py index e5a7f031f9d..262378d1dc8 100644 --- a/django/db/migrations/loader.py +++ b/django/db/migrations/loader.py @@ -292,8 +292,10 @@ class MigrationLoader(object): if all(m in applied for m in self.replacements[parent].replaces): continue raise InconsistentMigrationHistory( - "Migration {}.{} is applied before its dependency {}.{}".format( + "Migration {}.{} is applied before its dependency " + "{}.{} on database '{}'.".format( migration[0], migration[1], parent[0], parent[1], + connection.alias, ) ) diff --git a/docs/releases/1.10.1.txt b/docs/releases/1.10.1.txt index 88edfa80cfa..3e73483e376 100644 --- a/docs/releases/1.10.1.txt +++ b/docs/releases/1.10.1.txt @@ -65,3 +65,6 @@ Bugfixes * Reverted a few admin checks that checked ``field.many_to_many`` back to ``isinstance(field, models.ManyToManyField)`` since it turned out the checks weren't suitable to be generalized like that (:ticket:`26998`). + +* Added the database alias to the ``InconsistentMigrationHistory`` message + raised by ``makemigrations`` and ``migrate`` (:ticket:`27089`). diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py index b46f35f7ed2..b8c2cd81427 100644 --- a/tests/migrations/test_loader.py +++ b/tests/migrations/test_loader.py @@ -378,7 +378,10 @@ class LoaderTests(TestCase): loader.check_consistent_history(connection) recorder = MigrationRecorder(connection) recorder.record_applied('migrations', '0002_second') - msg = "Migration migrations.0002_second is applied before its dependency migrations.0001_initial" + msg = ( + "Migration migrations.0002_second is applied before its dependency " + "migrations.0001_initial on database 'default'." + ) with self.assertRaisesMessage(InconsistentMigrationHistory, msg): loader.check_consistent_history(connection)