Re-order all paths
Refs https://redmine.teklia.com/issues/3735
Depends #1490 (closed)
To be able to create a unique constraint on ElementPath (path, ordering)
, we need to reorder all existing ElementPath
instances with duplicate values of ordering
per path
.
No need to lookup element polygons here, we can simply rely on the pre-existing ordering and linearize it (basically ordering by ordering, element_id
) would be sufficient.
I wonder what is the best approach here:
- building a django command + a constraint as a migration: we need to fully run the django command before applying the migration, really cumbersome in production (and balsac).
- build a first django migration without DB transaction (so it's replayable again & again) then a second one to apply the constraint