🔨 chore(database): re-tighten getBuiltinAgent onConflict after 0109#15475
Merged
Conversation
…partial index
Now that migration 0109 has flipped agents_slug_user_id_unique to a partial
index (WHERE workspace_id IS NULL) in all environments, restore the precise
conflict arbiter { target: [slug, userId], where: isNull(workspaceId) } so
unexpected unique violations surface instead of being silently swallowed by the
bare onConflictDoNothing() transition form.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## canary #15475 +/- ##
=========================================
Coverage 70.84% 70.85%
=========================================
Files 3255 3255
Lines 321112 321115 +3
Branches 29340 35001 +5661
=========================================
+ Hits 227496 227510 +14
+ Misses 93434 93423 -11
Partials 182 182
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Jun 9, 2026
Closed
Closed
Closed
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.
💻 Change Type
🔗 Related Issue
Follow-up to #15472 / LOBE-9962 (workspace_id migration phase 4).
🔀 Description of Change
Migration 0109 turned
agents_slug_user_id_uniqueinto a partial index (WHERE workspace_id IS NULL). During the rollout, #15472 temporarily used a bareonConflictDoNothing()(no arbiter) ingetBuiltinAgentso the upsert worked regardless of whether the index was the legacy full unique or the new partial — avoiding a deploy-ordering footgun.Now that 0109 has flipped the index in every environment (verified:
agents_slug_user_id_uniqueisvalid,unique, predicateworkspace_id IS NULL), this restores the precise arbiter:so genuine/unexpected unique violations surface instead of being silently swallowed. Builtin agents are always workspace-less, so the predicate always holds.
🧪 How to Test
agent.test.ts114/114 pass against the partial index.