Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27089 closed Cleanup/optimization (fixed)

Add the database alias to InconsistentMigrationHistory message

Reported by: Alexander Holmbäck Owned by: Tim Graham
Component: Migrations Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Alexander Holmbäck)

In the file django/core/management/commands/makemigrations.py (line 97-100), an instance of MigrationLoader (loader) checks consistency on every database connection defined in settings.py.

for db in connections:
    connection = connection[db]
    if connection.settings_dict['ENGINE'] != 'django.db.backends.dummy':
        loader.check_consistent_history(connection)

The loader will then raise an InconsistentMigrationHistory exception for a connection whose migrations is not applied consistently, even if it's not to participate in the migration process.

I didn't expect makemigrations would check connections that isn't to be migrated. Also, the error message "Migration xxx is applied before its dependency xxx" (line 285 in db/migrations/loader.py) didn't indicate checked connection.

A more intuitive behavior would be to check only the connection that is to be migrated, or, if that isn't possible, include connection name in the error message.

Change History (4)

comment:1 by Tim Graham, 8 years ago

Has patch: set
Owner: changed from nobody to Tim Graham
Status: newassigned
Summary: commands/makemigrations.py runs MigrationLoader.check_consistent_history() for all database connectionsAdd the datbase alias to InconsistentMigrationHistory message
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

makemigrations doesn't run "per database" so that's why all connections are checked.

Accepting on the basis that the database alias should appear in the message. Thanks for that suggestion.

PR

comment:2 by Alexander Holmbäck, 8 years ago

Description: modified (diff)
Summary: Add the datbase alias to InconsistentMigrationHistory messageAdd the database alias to InconsistentMigrationHistory message

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In ad25fe7:

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

comment:4 by Tim Graham <timograham@…>, 8 years ago

In 46f60424:

[1.10.x] Fixed #27089 -- Added database alias to InconsistentMigrationHistory message.

Backport of ad25fe73506d80ffcaac135ad0a8d09552b70d70 from master

Note: See TracTickets for help on using tickets.
Back to Top