Problem/Motivation

I'm opening this issue to document something I experienced in my local testing environment. However, the reason it happens is well understood and avoidable, and I'm not sure we can (or should) fix it, other than by documenting it.

TL;DR: If any asset migrations are run after area migrations, they can overwrite the areas.

This is because asset migrations are designed to maintain their asset IDs when they are migrated, whereas area migrations will assign new IDs to the location assets that are created. Because asset ID's are auto-incrementing, this means that an an area will be assigned an ID automatically when it is migrated, which can then be overwritten by an asset with that same ID.

And not just "overwritten" - but "merged" with - because the field data for the areas will still exist in the database associated with the same asset ID. For example: the migrated assets will have the intrinsic geometry of the areas that came before them, along with having "is fixed" and "is location" set to TRUE.

So it is critical that area migrations happen after asset migrations, for this reason.

Steps to reproduce

  1. Run area migrations BEFORE running asset migrations
  2. Observe that areas are overwritten/merged with assets.

Proposed resolution

We already document the specific order in which migrations should be run in https://docs.farmos.org/hosting/migration/

Making this warning more prominent, and perhaps linking back to this issue would be worthwhile.

Comments

m.stenta created an issue. See original summary.

  • m.stenta committed f3db655 on 2.x
    Issue #3203228: Running migrations out of order can result in data...
m.stenta’s picture

Status: Active » Closed (won't fix)

I added a specific point about this to the "Important considerations" section of the migrations docs, with a link back to this issue.

I'm going to close this as "won't fix" because I still think it is more important to maintain asset IDs across the migration than it is to fix this potential issue.