Validate that only one program exists per channel - #57
Merged
Conversation
The one-to-one mapping already gives the channel a unique constraint, but without a matching UniqueEntity constraint the admin got a database error instead of a form error when creating a second program for a channel. The join column is now also explicitly not null (the form has always required a channel), and the standalone index on the boolean enabled column - which no query benefits from - is dropped. The constraints are covered by a functional test against a real database. Fixes #52 Claude-Session: https://claude.ai/code/session_01Mt12J8vdGwwWg4V23uoEf9
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.x #57 +/- ##
=========================================
Coverage 84.79% 84.79%
Complexity 104 104
=========================================
Files 21 21
Lines 546 546
=========================================
Hits 463 463
Misses 83 83 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The functional-tests CI job loads the Sylius fixtures, which already contain the en_US locale and the FASHION_WEB channel. Claude-Session: https://claude.ai/code/session_01Mt12J8vdGwwWg4V23uoEf9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #52.
What changed
UniqueEntityonchannelinconfig/validation/Program.xml(witherrorPath: channel, in the plugin's validation group), so creating a second program for the same channel yields a form error on the channel field instead of a database constraint violation (500). English and Danish messages added.nullable="false"(the form has always required a channel) and keeps its unique constraint; the standaloneidx_enabledindex on the boolean column is dropped — the only query filters on channel (already unique) and enabled, so it never helped.ProgramValidationTest(functional suite, skipped without a database) covering the duplicate-channel rejection, a program on another channel being accepted, and the existing duplicate-program-id rule.Upgrade notes
doctrine:migrations:diffwill produceDROP INDEX idx_enabledandALTER TABLE … CHANGE channel_id channel_id INT NOT NULL. The latter requires that no program row has a NULL channel — which the form has never allowed.https://claude.ai/code/session_01Mt12J8vdGwwWg4V23uoEf9