Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Sep 9, 2025

Apologies for the 32k LOC, it belongs mostly to deleting the .xcdatamodels and associated .xcmappings, the actual changes are the ~90 additions.

This PR continues the work of core data pruning started by #15987, in this one do a second pass by:

  • Removing .xcdatamodels from 30 to 59, making the minimum version model 60 (2021-12-22)
  • Removingmapping migrations 31to32, 32to33, 39to40, 42to43, and 45to46
  • Updating tests

There is no updates to the migration paths or any logic has been changed, it's just a code removal & test updates.

Steps to reproduce/Testing information

As with the first part, this is not very straight-forward to test, but has been live for a month now so we should be certain there are no major issues.

Ultimately we'd want the merchant to not crash if they happen to be on a model version that has been deleted when a migration is performed. This crash is expected with an iterative migration if a step is missing, but won't happen with the direct migration. If the worst happens and they crash due being unable to perform iterative migration, the app already performs a direct migration as a fallback, which is what we leverage directly via the threshold check when we can.

I added instructions on the P2 at p91TBi-drE-p2 on how I initially tested it by deleting 120 models instead, since this was the oldest available in TestFlight it allows us to simulate what would happen when a migration is needed and the threshold is hit.

At the moment of writing this PR the latest available TF version is 22.5, which as per MIGRATIONS.md was using model 121, so I'll use that as example. You can:

  • Install oldest TF version, login and play around, this should set the model 121 in your device
  • Set oldestSupportedDataModel to 122 or higher (including the model version that your TF build should be in), so it determines that anything below is an old model and should be purged entirely.
  • Delete the remaining .xcdatamodels up till 122 in Xcode, then run the app from Xcode in the same device you previously ran the TF build.
  • Following the traditional path, we would see a crash here since the iterative migration is broken (missing steps). Instead, since the model is below the threshold, we should migrate directly to the latest version, skipping the iterative migration path.
  • Observe there is no crash when running the app, and that works normally. From testing, the Order list will appear empty, a simple pull-to-refresh should repopulate it.

@dangermattic
Copy link
Collaborator

dangermattic commented Sep 9, 2025

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@iamgabrielma iamgabrielma marked this pull request as ready for review September 9, 2025 08:19
@wpmobilebot
Copy link
Collaborator

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16109-9772c81
Version23.2
Bundle IDcom.automattic.alpha.woocommerce
Commit9772c81
Installation URL3lm9okueo0a18
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@iamgabrielma iamgabrielma added type: task An internally driven task. type: technical debt Represents or solves tech debt of the project. labels Sep 9, 2025
@iamgabrielma iamgabrielma added this to the 23.3 milestone Sep 9, 2025
@iamgabrielma
Copy link
Contributor Author

I'll be AFK the rest of this week, if all looks good feel free to merge, otherwise I'll address any feedback next week 🙇

@itsmeichigo itsmeichigo self-assigned this Sep 10, 2025
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test instruction seems to be outdated, so I just ran the code after installing the oldest build in TestFlight (22.5). The app didn't crash so 👍

@itsmeichigo itsmeichigo merged commit 538663a into trunk Sep 10, 2025
24 of 26 checks passed
@itsmeichigo itsmeichigo deleted the task/WOOMOB-1308-remove-old-cd-models branch September 10, 2025 03:07
@iamgabrielma
Copy link
Contributor Author

Thanks for the review and testing!

The test instruction seems to be outdated, so I just ran the code after installing the oldest build in TestFlight (22.5). The app didn't crash so 👍

The test instructions are outdated indeed, sorry for that 😅 , we simplified the behavior here: 6080964 so rather than having to set a constants to compare model versions, we just rely on the existence of the model itself.

@iamgabrielma iamgabrielma changed the title [Core Data] Remove old models. Part 2 (30-49) [Core Data] Remove old models. Part 2 (30-59) Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task. type: technical debt Represents or solves tech debt of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants