fix(backend): derive membership mock ancestor IDs from the channel row - #1048
Merged
Conversation
mockChannelMembership invented UUIDs for ancestor channel-entity ID columns, so inserting its output violated FK constraints — surfaced by a fork's pnpm seed. Add deriveMembershipChannelIdColumns, which reads ancestor IDs off the channel entity row itself (overrides still win), and keep the invented-ID generator for wire/response mocks only, with a warning not to insert its output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
mockChannelMembershipfilled ancestor channel-entity ID columns with invented UUIDs (viagenerateMockMembershipChannelIdColumns). That is fine for wire/response mocks, but the same output was used for database inserts, where invented ancestor IDs violate FK constraints. This surfaced in a fork (projectcampus) during itspnpm seedphase.Fix
deriveMembershipChannelIdColumns: derives ancestor ID columns from the channel entity row itself (nullable ancestors stay null,overrideIdsstill win, target column stays identical to the denormalizedchannelId). Safe for inserts — no IDs are invented.mockChannelMembershipnow uses the derive helper;ChannelRefaccepts the ancestor ID columns off the row when present.generateMockMembershipChannelIdColumnsis kept for wire/response mocks only, with a doc warning never to insert its output.Verification
pnpm --filter backend tspasses; pre-commit hook ran biome + full-repo typecheck + OpenAPI/SDK generation (SDK unchanged).🤖 Generated with Claude Code