Skip to content

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Jul 8, 2025

Summary

This adds a dependent: :restrict_with_error to the has_many association between spree_adjustments and spree_adjustment_reasons. It also adds a corresponding foreign key constraint.

If the foreign key constraint fails, the developer gets a suggestion to nil the adjustment_reason_id column in the spree_adjustments table for those records that have an adjustment reason ID with not corresponding adjustment reason. We don't want to delete adjustment records.

Extracted from #6240

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@mamhoff mamhoff requested a review from a team as a code owner July 8, 2025 12:17
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Jul 8, 2025
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.22%. Comparing base (b67dbb7) to head (9e1ca7f).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6303      +/-   ##
==========================================
+ Coverage   87.99%   89.22%   +1.22%     
==========================================
  Files         796      952     +156     
  Lines       16645    20060    +3415     
==========================================
+ Hits        14647    17898    +3251     
- Misses       1998     2162     +164     

☔ 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.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Nice. I think we should be a bit nicer to admins and present an validation error instead of an exception. WDYT?

@mamhoff mamhoff force-pushed the adjustment-reason-dependent branch from 8dbba6d to 584e5ec Compare July 8, 2025 15:04
@tvdeyen tvdeyen added this to the 4.6 milestone Jul 8, 2025
@tvdeyen tvdeyen moved this to In Progress in Solidus Public Roadmap Jul 8, 2025
mamhoff added 2 commits July 23, 2025 19:22
We should not delete adjustment reasons if there are adjustments created
with them.
This migration will fail if there are any adjustments with invalid
adjustment reason IDs. The suggested path of action for store owners is
to change those adjustment reason IDs to NULL, because we don't want to
accidentally lose adjustments.
@tvdeyen tvdeyen force-pushed the adjustment-reason-dependent branch from 584e5ec to 9e1ca7f Compare July 23, 2025 17:22
@tvdeyen tvdeyen enabled auto-merge July 23, 2025 17:23
@tvdeyen tvdeyen merged commit 13a7bbd into solidusio:main Jul 23, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Solidus Public Roadmap Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem
Projects
Development

Successfully merging this pull request may close these issues.

2 participants