Restore the auth.users signup trigger lost in the dev2 move - #1021
Merged
Merged
Conversation
The 2026-09-25 move to the self-hosted stack dumped app schemas only, so on_auth_user_created on auth.users was dropped and signups since then have no profile. Recreate it and backfill the rows it would have made. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
ThreatCrush Security Scan53 finding(s) HIGH/CRITICAL: 1 | MEDIUM: 17 | LOW: 35
…and 3 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
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.
Cause
On 2026-09-25 the Supabase project moved from Supabase cloud to a self-hosted stack on dev2. The move dumped DDL for the app schemas only, and pg_dump files a trigger under its table's schema, so every trigger ON
auth.userswas dropped while thepublicfunctions they call survived. Every signup since the cutover is missing what the trigger creates.What this restores
Replaying every
.sqlfile in the repo in apply order, the only object created on anauth.*orstorage.*table that still exists at the end is:on_auth_user_createdAFTER INSERT ONauth.users->public.handle_new_user()Storage policies (
storage.objects/storage.buckets): none in the migrations, so none to restore.Backfill
public.profiles (email, handle, referred_by, referral_code, user_id)for everyauth.usersrow with no profile, with the function's upsert on email. The function drawsreferral_codeat random; the backfill derives it from the user id (substr(md5(id), 1, 8), same shape, deterministic) and skips a user whose derived code is already taken (the CHECK query would show them).public.referralsfor users created since 2026-09-25 whose signup metadata named an existing referral code, as the function does. Side effect: each such row carries the defaultcredit_cents($50), which only pays out when the invitee pays.Idempotent throughout (
drop trigger if exists+create, anti-joined inserts). Nothing in it sends email or calls a webhook.Migration:
sites/sh1pt.com/supabase/migrations/20260926210000_restore_auth_storage_lost_in_dev2_move.sqlNot yet applied to dev2; will be dry-run and applied from the operator session.
🤖 Generated with Claude Code