[Local Catalog] Add remote ID for attributes #16219
Merged
+282
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Part of: WOOMOB-1339
Description
This PR updates our attribute schemas to support both Global and Local attributes.
Global attributes are defined independently, and can be reused across products/variations with a many to many relationship. Local attributes are defined per-product or variation, and have a one to many relationship.
We model this with two different tables, but it would make it more difficult to deal with the attributes as we'd need two relationships from the product/variation to its attributes.
Instead, I've opted to mirror the API approach.
idremains, as an auto-generated integer, but now the attribute tables include aremoteAttributeID. Global attributes have a positive integer ID, while local attributes have the ID0.This approach means the data is denormalised.
Steps to reproduce
This can't be properly tested in the app yet, as the database isn't used in the POS UI.
You can put breakpoints in the
POSCatalogPersistenceService.replaceAllCatalogData(_:siteID:)function and check that they are created, or find the SQLite database file from your simulator and open it with a tool like SQLPro... but mostly, just checking that it logs the expected number of products/variations being synced should be enough. We'll see any issues soon enough when it's in the UI, anyway.You can get the database file for a running simulator by:
xcrun simctl get_app_container booted com.automattic.woocommerce datain the terminalDocumentswoo-local.sqliteScreenshots
RELEASE-NOTES.txtif necessary.