Skip to content

Conversation

@joshheald
Copy link
Contributor

@joshheald joshheald commented Sep 11, 2025

Description

This PR adds the ability to store more than one site's data at a time.

Changes

  • Updates all our GRDB entities which currently use a remote ID as their primary key, to include siteID in their primary key.
  • Changes full sync to delete only the site being synced, not all sites, before inserting data

Steps to reproduce

  1. Launch the app logged in to a WPCom account with multiple POS-eligible sites
  2. Observe that your site data synced on login (or was checked and found to be less than 24 hours old)
  3. Switch to a different POS site – observe that site's data is synced
  4. Switch back to the original site – observe that the data does not need to be synced, because it's already there and less than 24 hrs old.

Screenshots

CleanShot 2025-09-11 at 16 50 05@2x

The purple boxes are site 1, the orange boxes are site 2


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@joshheald joshheald added this to the 23.3 milestone Sep 11, 2025
@joshheald joshheald added type: task An internally driven task. status: feature-flagged Behind a feature flag. Milestone is not strongly held. feature: POS labels Sep 11, 2025
@joshheald joshheald requested a review from jaclync September 11, 2025 15:36
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 11, 2025

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 Numberpr16120-43c7bf6
Version23.2
Bundle IDcom.automattic.alpha.woocommerce
Commit43c7bf6
Installation URL08ai327r8io58
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for figuring out the compound primary keys in GRDB :shipit: there are some failing test cases in CI that seem related.

private static func createProductAttributeTable(_ db: Database) throws {
try db.create(table: "productAttribute") { productAttributeTable in
// This table holds local product attributes only. Global attributes belong to a site.
productAttributeTable.autoIncrementedPrimaryKey("id").notNull()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is it worth adding a separate column for the "attribute ID" from the API response, if we ever want to differentiate between local vs. global attributes? Similar question for the variation attribute entity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a separate task on my list (possibly not in linear yet, I can't remember) but I'm planning to make the schema support both types properly before we finalise it. It's just less urgent than this change.

Comment on lines -41 to +45
private extension PersistedProductVariationAttribute {
extension PersistedProductVariationAttribute {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: any reasons for making this extension internal while the same one in other classes stay private?

Copy link
Contributor Author

@joshheald joshheald Sep 12, 2025

Choose a reason for hiding this comment

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

In order to refer to the column names by for the variation's attributes relationship:

public static let attributes = hasMany(PersistedProductVariationAttribute.self,
                                           using: ForeignKey([PersistedProductVariationAttribute.CodingKeys.siteID.stringValue,
                                                              PersistedProductVariationAttribute.CodingKeys.productVariationID.stringValue],
                                                             to: primaryKey))

However, that relationship isn't actually working (it's one of the causes of the failing tests) so when I've fixed it I'll check whether this can go back to private or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I actually needed to make the others internal too!

@joshheald joshheald merged commit 4d19368 into trunk Sep 12, 2025
14 checks passed
@joshheald joshheald deleted the woomob-1330-woo-poslocal-catalog-support-storage-of-multiple-sites-at branch September 12, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS status: feature-flagged Behind a feature flag. Milestone is not strongly held. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants