Fixed #27089 -- Added database alias to InconsistentMigrationHistory message.

This commit is contained in:
Tim Graham 2016-08-18 18:17:01 -04:00
parent 80c03b06ad
commit ad25fe7350
3 changed files with 10 additions and 2 deletions

View File

@ -292,8 +292,10 @@ class MigrationLoader(object):
if all(m in applied for m in self.replacements[parent].replaces): if all(m in applied for m in self.replacements[parent].replaces):
continue continue
raise InconsistentMigrationHistory( 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], migration[0], migration[1], parent[0], parent[1],
connection.alias,
) )
) )

View File

@ -65,3 +65,6 @@ Bugfixes
* Reverted a few admin checks that checked ``field.many_to_many`` back to * Reverted a few admin checks that checked ``field.many_to_many`` back to
``isinstance(field, models.ManyToManyField)`` since it turned out the checks ``isinstance(field, models.ManyToManyField)`` since it turned out the checks
weren't suitable to be generalized like that (:ticket:`26998`). 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`).

View File

@ -378,7 +378,10 @@ class LoaderTests(TestCase):
loader.check_consistent_history(connection) loader.check_consistent_history(connection)
recorder = MigrationRecorder(connection) recorder = MigrationRecorder(connection)
recorder.record_applied('migrations', '0002_second') 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): with self.assertRaisesMessage(InconsistentMigrationHistory, msg):
loader.check_consistent_history(connection) loader.check_consistent_history(connection)