Changes between Initial Version and Version 1 of Ticket #28862, comment 6


Ignore:
Timestamp:
Dec 5, 2017, 9:51:46 PM (7 years ago)
Author:
Ramiro Morales

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28862, comment 6

    initial v1  
    11This is what I've found so far:
    22
    3 It seems the optimization introduced in e470f311d654267ec86f9a6325ec500345b9dff2 (later refactored in 49f4c9f4c61885189d136d7073c26ecc91b482b1) by which a sequence of schema migrations operations like this:
     3It seems the optimization introduced in e470f311d654267ec86f9a6325ec500345b9dff2 (later refactored in 49f4c9f4c61885189d136d7073c26ecc91b482b1) by which a sequence of schema migration operations like this:
    44
    55{{{
     
    88}}}
    99
     10which is correctly created by `django.db.migrations.autodetector.MigrationAutodetector._build_migration_list()`
    1011gets swapped to
    1112
     
    1516}}}
    1617
    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.
     18This 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.
    1819
    19 if it did, then it would discover it can't optimize the `AlterIndexTogether` to be after the `RemoveField` whcih is that the OP reports.
     20if 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.
    2021
    21 Example is for `Meta.index_together` but affects also al least `Meta.unique_together` too. AFAICT fixing this might involve some non-trivial refactoring.
     22Example is for `Meta.index_together` but affects also at least `Meta.unique_together` too.  AFAICT fixing this might involve some non-trivial refactoring. 
    2223
    2324I'm open to confirmation/rebuttal and to ideas on how this could be solved.
Back to Top