Skip to content

Adjust Size model and create SizeRangeSize for sizes_sizegroup join table#2679

Draft
Copilot wants to merge 2 commits into
masterfrom
copilot/adjust-size-data-model
Draft

Adjust Size model and create SizeRangeSize for sizes_sizegroup join table#2679
Copilot wants to merge 2 commits into
masterfrom
copilot/adjust-size-data-model

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

The DB migration in dropapp#821 removes sizes.sizegroup_id and sizes.seq, replacing the direct FK with a new sizes_sizegroup cross-reference table. This PR updates the BE models and all query code to match.

Model changes

  • Size: removed seq and size_range (sizegroup_id FK) fields
  • SizeRangeSize (new): maps sizes_sizegroup with size_id → sizes and sizegroup_id → sizegroup, using CompositeKey("size", "size_range")
  • models/__init__.py: registers SizeRangeSize in MODELS

Query updates

All code that previously joined Size to SizeRange directly now routes through SizeRangeSize:

# Before: direct join on shared column (column no longer exists)
Product.select(...).left_outer_join(Size, on=(Product.size_range == Size.size_range))

# After: two-step lookup via join table
SizeRangeSize.select(SizeRangeSize, Size).join(Size)
# or for traversal queries:
Size.select(Size.id).join(SizeRangeSize).join(SizeRange).join(Product)

Affected files: loaders.py (SizesForSizeRangeLoader), warehouse/box/crud.py (bulk create), mobile_distribution/crud.py, cron/data_faking.py.

Test data

  • Removed size_range from size fixtures
  • Added size_range_size.py test data module; inserted into _NAMES ordering after size

@pylipp
Copy link
Copy Markdown
Contributor

pylipp commented Apr 21, 2026

@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.77%. Comparing base (4ab7e36) to head (7677001).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2679   +/-   ##
=======================================
  Coverage   76.77%   76.77%           
=======================================
  Files         300      300           
  Lines       22182    22182           
  Branches     2232     2232           
=======================================
  Hits        17030    17030           
  Misses       5104     5104           
  Partials       48       48           
Flag Coverage Δ
frontend 69.10% <ø> (ø)
sharedComponents 68.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants