Skip to content

[WellSQL Migration] Remove Unnecessary WCAttributeTermModel Table/Code from wp-fluxc #14453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Aug 11, 2025

Closes: AINFRA-549


Description

What started with migrating this WCAttributeTermModel table, ended-up with removing it instead. This was done because apart from deleting and inserting attribute terms into a table (writing), see usage of insertAttributeTermsFromScratch(...), no flows or code was reading from that table, nor any table was depending on this table, its column are any of its stored values (ie. WCGlobalAttributeModel).

I tried to understand why this table existed in the first place, and whether some flow/code removal just didn't completely cleaned this up (in the past), following a few FluxC related PRs, but couldn't connect the dots, eventually assuming that this table was only used with FluxC's example app and not within WCAndroid itself at all, see PRs:

I actually lost more time trying to connect the dots rather than migrating/removing this table... 😭

FYI: The WCAttributeTermModel class is kept on purpose and so as to reduce the amount of code change this would produce, should that "domain" related class were also deleted.

PS: As part of AINFRA-552 I'll also remove this termsId column from WCGlobalAttributeModel, not seeing it being used as well.


Testing information

  1. Go to the Products screen.
  2. Find a Variable product or change a Physical product to a Variable product.
  3. Click on Add variations to navigate to the Add attribute screen.
  4. Tap to select an existing attribute (like Color or Size) and see the list of option of that attribute.
  5. Tap on a couple of options and then click NEXT twice, then press the GENERATE VARIATION button and select Generate all variations, following by OK when the dialog appears.
  6. Click on Add variations again to navigate to the Variations screen where you'll see the variations you added.
  7. Go back and click the SAVE button to have these changes apply to the product.

EXTRA

If you want you could test this flow above on trunk and see this WCAttributeTermModel table being populated with (Color or Size) attribute values and various options. You will also notice that, for a particular attribute, previous options are deleted as new options are being shown on screen. This means that only the new options ending-up being saved on that table, which is weird by itself.


  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

FYI: The 'WCAttributeTermModel' class is kept on purpose and so as to
reduce the amount of code change this would produce, should that
"domain" related class were also deleted.
@ParaskP7 ParaskP7 added this to the 23.1 milestone Aug 11, 2025
@ParaskP7 ParaskP7 requested a review from Copilot August 11, 2025 13:31
@ParaskP7 ParaskP7 added the type: technical debt Represents or solves tech debt of the project. label Aug 11, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the unnecessary WCAttributeTermModel table and related code from the FluxC library as part of a WellSQL migration. The change eliminates database table creation, persistence logic, and related functionality while keeping the model class as a simple data class to minimize code changes.

  • Increments database version and adds migration to drop the WCAttributeTermModel table
  • Removes database persistence functionality from WCAttributeTermModel and converts it to a plain data class
  • Eliminates term-related methods and imports from store and utility classes

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
WellSqlConfig.kt Increments DB version to 227 and adds migration to drop WCAttributeTermModel table
WCGlobalAttributeStoreTest.kt Removes WCAttributeTermModel from test configuration
WCGlobalAttributeStore.kt Removes term insertion logic and related imports
WCGlobalAttributeSqlUtils.kt Removes all term-related database operations and utility methods
WCAttributeTermModel.kt Converts from WellSQL table model to simple data class
WCGlobalAttributeModel.kt Removes term-related functionality and product attribute conversion methods

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 11, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitcd87bed
Direct Downloadwoocommerce-wear-prototype-build-pr14453-cd87bed.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 11, 2025

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

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitcd87bed
Direct Downloadwoocommerce-prototype-build-pr14453-cd87bed.apk

@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.01%. Comparing base (95947c2) to head (cd87bed).

Files with missing lines Patch % Lines
...luxc/model/attribute/terms/WCAttributeTermModel.kt 0.00% 9 Missing ⚠️
...rdpress/android/fluxc/persistence/WellSqlConfig.kt 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14453      +/-   ##
============================================
+ Coverage     38.00%   38.01%   +0.01%     
  Complexity     9229     9229              
============================================
  Files          1993     1993              
  Lines        112560   112506      -54     
  Branches      14853    14843      -10     
============================================
  Hits          42773    42773              
+ Misses        65891    65837      -54     
  Partials       3896     3896              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ParaskP7 ParaskP7 marked this pull request as ready for review August 11, 2025 14:06
@ParaskP7 ParaskP7 requested a review from wzieba August 11, 2025 14:06
Copy link
Contributor

@wzieba wzieba left a comment

Choose a reason for hiding this comment

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

Looks good! Even better than migration 🙂

FYI: The WCAttributeTermModel class is kept on purpose and so as to reduce the amount of code change this would produce, should that "domain" related class were also deleted.

Do we plan to track it somewhere?

@ParaskP7
Copy link
Contributor Author

Thanks for the review @wzieba ! 🙇 ❤️ 🚀

Looks good! Even better than migration 🙂

💯 😄

Do we plan to track it somewhere?

How do you mean tracking it? To be honest, I just mentioned it without necessarily having an associated TODO with that specific FYI, just because I don't think it's worth revisiting this for what we're trying to do here, the overall migration work, just so we avoid deep dives that could make us lose focus from our ultimate goal, removing the WellSQL dependency. Wdyt? 🤔

@wzieba
Copy link
Contributor

wzieba commented Aug 12, 2025

I understood that the only reason to keep WCAttributeTermModel is to "reduce the amount of code change this would produce". If this class is not needed in your opinion, then I think it's a valuable result of your research, and we should create some action item from this (GH or Linear issue).

@ParaskP7
Copy link
Contributor Author

...then I think it's a valuable result of your research...

Fare enough @wzieba ! 👍

...and we should create some action item from this (GH or Linear issue).

Done: AINFRA-1123 (created as a sub-task of AINFRA-549 itself)

@wzieba
Copy link
Contributor

wzieba commented Aug 12, 2025

Thanks!

@ParaskP7
Copy link
Contributor Author

FYI: Just to be on the 100% safe side of thing, before I merge this, I'll ping a product engineer to give us an extra 👍 on this and the subsequent change I am working on atm (AINFRA-552 - removing termsId column from WCGlobalAttributeModel).

@malinajirka can you skim review this and give us a 👍 on it, maybe even connect the dots on how come we had this WCAttributeTermModel in the first place, plus why us needing this termsId column on WCGlobalAttributeModel, many thanks for your help? 🙏

@malinajirka
Copy link
Contributor

Thanks for the ping @ParaskP7 !

I don't have any previous context and unfortunately, I wasn't able to find any explanation during my quick research. Either case, I agree it seems it's not used + Claude also agrees + Wojtek agrees + you agree, so I think we are good to merge this 🥳!

@ParaskP7
Copy link
Contributor Author

I don't have any previous context and unfortunately, I wasn't able to find any explanation during my quick research.

Thanks for the extra 👍 on this @malinajirka , much appreciated! 🙇 ❤️

Either case, I agree it seems it's not used + Claude also agrees + Wojtek agrees + you agree, so I think we are good to merge this 🥳!

🥳 🚀

@ParaskP7 ParaskP7 merged commit c42d30f into trunk Aug 13, 2025
17 checks passed
@ParaskP7 ParaskP7 deleted the db/remove-unnecessary-wc-attribute-term-model-table-from-wp-fluxc branch August 13, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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