feat(profiles): toggle-admin writes is_admin to profile_private (split Phase 3)#663
Merged
Merged
Conversation
…t Phase 3) The dual-write mirror is removed in Phase 3 — profiles.is_admin is a dead column and writing it would silently do nothing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Updates the admin “toggle admin” API endpoint to write the admin flag to the new canonical table (profile_private) as part of the Phase 3 profiles split, preventing post-migration no-ops when the legacy mirror is removed.
Changes:
- Switches the update target from
profiles.is_admintoprofile_private.is_admin. - Updates the filter key from
idtouser_id. - Adds an inline comment documenting the Phase 3 rationale.
Comments suppressed due to low confidence (1)
server/api/admin/users/toggle-admin.post.ts:31
- This update still returns
{ success: true }even if zero rows are updated (e.g. if there is noprofile_privaterow for the user, or if the filter column is wrong). PostgREST updates commonly return no error on 0-row updates, so it’s worth selecting the updated row(s) and failing with a 404 to avoid a silent no-op—especially now that the target table/key changed.
const { error } = await supabase.from('profile_private').update({ is_admin: isAdmin }).eq('user_id', userId);
if (error) {
throw createError({ statusCode: 500, statusMessage: error.message });
}
| // profiles split Phase 3: is_admin is canonical on profile_private (the | ||
| // dual-write mirror from profiles is gone — writing profiles.is_admin here | ||
| // would silently do nothing). | ||
| const { error } = await supabase.from('profile_private').update({ is_admin: isAdmin }).eq('user_id', userId); |
Comment on lines
+24
to
+27
| // profiles split Phase 3: is_admin is canonical on profile_private (the | ||
| // dual-write mirror from profiles is gone — writing profiles.is_admin here | ||
| // would silently do nothing). | ||
| const { error } = await supabase.from('profile_private').update({ is_admin: isAdmin }).eq('user_id', userId); |
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.
Companion to the Phase 3 Supabase migration (profiles split):
profile_privatebecomes canonical and the dual-write trigger is removed, so the admin toggle must writeprofile_private.is_admindirectly — writingprofiles.is_adminwould silently stop taking effect.One-line change (service client, admin-gated route). Full unit suite green: 4635/4635.
Merge after the Phase 3 Supabase migration deploys. Until this merges, toggling admin status is the one flow that would no-op post-migration (it logs via the legacy-write detector); everything else is already repointed.
🤖 Generated with Claude Code