Skip to content

feat(profiles): toggle-admin writes is_admin to profile_private (split Phase 3)#663

Merged
SomethingNew71 merged 1 commit into
mainfrom
feature/profiles-split-phase3-toggle-admin
Jul 13, 2026
Merged

feat(profiles): toggle-admin writes is_admin to profile_private (split Phase 3)#663
SomethingNew71 merged 1 commit into
mainfrom
feature/profiles-split-phase3-toggle-admin

Conversation

@SomethingNew71

Copy link
Copy Markdown
Collaborator

Companion to the Phase 3 Supabase migration (profiles split): profile_private becomes canonical and the dual-write trigger is removed, so the admin toggle must write profile_private.is_admin directly — writing profiles.is_admin would 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

…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>
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
classicminidiy Ready Ready Preview, Comment Jul 13, 2026 6:11pm

Request Review

Copilot AI review requested due to automatic review settings July 13, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_admin to profile_private.is_admin.
  • Updates the filter key from id to user_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 no profile_private row 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);
@SomethingNew71
SomethingNew71 merged commit 98b8690 into main Jul 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants