Changes between Initial Version and Version 1 of Ticket #28862, comment 6
- Timestamp:
- Dec 5, 2017, 9:51:46 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28862, comment 6
initial v1 1 1 This is what I've found so far: 2 2 3 It seems the optimization introduced in e470f311d654267ec86f9a6325ec500345b9dff2 (later refactored in 49f4c9f4c61885189d136d7073c26ecc91b482b1) by which a sequence of schema migration soperations like this:3 It seems the optimization introduced in e470f311d654267ec86f9a6325ec500345b9dff2 (later refactored in 49f4c9f4c61885189d136d7073c26ecc91b482b1) by which a sequence of schema migration operations like this: 4 4 5 5 {{{ … … 8 8 }}} 9 9 10 which is correctly created by `django.db.migrations.autodetector.MigrationAutodetector._build_migration_list()` 10 11 gets swapped to 11 12 … … 15 16 }}} 16 17 17 This is because the `references_field()` method of `django.db.migrations.operations.AlterIndexTogether` considers only the final set of `index_together` fields to conclude there is no overlap in field affected by the two operations. This reasoning might be valid when reordering operation sequences which involve e.g. `AddField` But when it's interacting with `RemoveField` (and `RenameField`?) it needs to consider the _initial_ set of `index_together` fields instead.18 This is because the `references_field()` method of `django.db.migrations.operations.AlterIndexTogether` considers only the final set of `index_together` fields to conclude there is no overlap in fields affected by the two operations. This reasoning might be valid when reordering operation sequences which involve e.g. `AddField` But when it's interacting with `RemoveField` (and `RenameField`?) it needs to consider the _initial_ set of `index_together` fields instead. 18 19 19 if it did, then it would discover it can't optimize the `AlterIndexTogether` to be after the `RemoveField` wh cih is thatthe OP reports.20 if it did, then it would discover it can't optimize the `AlterIndexTogether` to be after the `RemoveField` which is the origin of the crash the OP reports. 20 21 21 Example is for `Meta.index_together` but affects also a l least `Meta.unique_together` too. AFAICT fixing this might involve some non-trivial refactoring.22 Example is for `Meta.index_together` but affects also at least `Meta.unique_together` too. AFAICT fixing this might involve some non-trivial refactoring. 22 23 23 24 I'm open to confirmation/rebuttal and to ideas on how this could be solved.