Skip to content

Restore the auth.users signup trigger lost in the dev2 move - #1021

Merged
ralyodio merged 1 commit into
masterfrom
fix/restore-dev2-lost-auth-storage
Sep 26, 2026
Merged

ralyodio merged 1 commit into
masterfrom
fix/restore-dev2-lost-auth-storage

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

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.users was dropped while the public functions they call survived. Every signup since the cutover is missing what the trigger creates.

What this restores

Replaying every .sql file in the repo in apply order, the only object created on an auth.* or storage.* table that still exists at the end is:

  • trigger on_auth_user_created AFTER INSERT ON auth.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 every auth.users row with no profile, with the function's upsert on email. The function draws referral_code at 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.referrals for 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 default credit_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.sql

Not yet applied to dev2; will be dry-run and applied from the operator session.

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

53 finding(s)

HIGH/CRITICAL: 1 | MEDIUM: 17 | LOW: 35

Severity Rule Location
HIGH js-host-header-trust packages/bots/wechat/src/index.ts:405
MEDIUM redos-nested-quantifier packages/actions-fleet-core/src/action-pack/schema.ts:3
MEDIUM redos-nested-quantifier packages/core/src/setup-helpers.ts:583
MEDIUM sql-template-interpolation packages/migrate/src/engines/mysql.ts:133
MEDIUM sql-template-interpolation packages/migrate/src/engines/postgres.ts:276
MEDIUM sql-template-interpolation packages/migrate/src/transforms.ts:178
MEDIUM redos-nested-quantifier packages/policy/src/rules/bundle-id.ts:3
MEDIUM sql-string-concatenation packages/targets/deploy-wordpress/src/index.ts:154
MEDIUM redos-nested-quantifier packages/targets/desktop-linux/src/index.ts:19
MEDIUM redos-nested-quantifier packages/targets/desktop-mac/src/index.ts:15
MEDIUM redos-nested-quantifier packages/targets/desktop-steamos/src/index.ts:28
MEDIUM redos-nested-quantifier packages/targets/mobile-android/src/index.ts:9
MEDIUM redos-nested-quantifier packages/targets/mobile-ios/src/index.ts:11
MEDIUM redos-nested-quantifier packages/targets/tv-androidtv/src/index.ts:14
MEDIUM redos-nested-quantifier packages/targets/tv-firetv/src/index.ts:13
MEDIUM redos-nested-quantifier packages/targets/tv-tvos/src/index.ts:14
MEDIUM redos-nested-quantifier packages/targets/tv-webos/src/index.ts:26
MEDIUM js-unescaped-html-sink sites/sh1pt.com/app/blog/[slug]/page.tsx:76
LOW secret-generic-credential packages/affiliates/skimlinks/src/index.test.ts:25
LOW secret-generic-credential packages/affiliates/skimlinks/src/index.test.ts:71
LOW secret-generic-api-key packages/affiliates/sovrn/src/index.ts:28
LOW secret-generic-credential packages/agent-providers/opencode/src/__tests__/opencode.test.ts:99
LOW js-nosql-injection packages/ai/amazon-bedrock/src/index.test.ts:121
LOW secret-generic-credential packages/ai/amazon-bedrock/src/index.ts:9
LOW secret-generic-credential packages/ai/amazon-bedrock/src/index.ts:10
LOW secret-generic-credential packages/ai/amazon-bedrock/src/index.ts:11
LOW secret-generic-credential packages/bridges/matrix/src/index.ts:58
LOW secret-generic-credential packages/bridges/matrix/src/index.ts:59
LOW secret-generic-credential packages/bridges/slack/src/index.test.ts:259
LOW secret-generic-credential packages/captcha/captchasolver/src/index.ts:34
LOW secret-generic-credential packages/cli/src/commands/secrets.ts:189
LOW secret-generic-credential packages/cloud/linode/src/index.ts:15
LOW secret-generic-credential packages/migrate/src/platforms/index.test.ts:116
LOW secret-generic-credential packages/observability/sentry/src/index.ts:15
LOW secret-generic-credential packages/outreach/producthunt/src/index.ts:103
LOW secret-generic-credential packages/promo/posthog/src/index.ts:23
LOW secret-generic-credential packages/scanners/threatcrush/test/scan-output.txt:35
LOW secret-generic-credential packages/scanners/threatcrush/test/scan-output.txt:40
LOW secret-database-url packages/scanners/threatcrush/test/scan-output.txt:54
LOW secret-generic-credential packages/security/snyk/src/index.ts:26
LOW secret-generic-credential packages/social/hashnode/src/index.ts:4
LOW secret-generic-credential packages/social/linkedin/src/index.ts:3
LOW secret-generic-credential packages/social/linkedin/src/index.ts:4
LOW secret-generic-credential packages/social/medium/src/index.ts:4
LOW secret-generic-credential packages/social/snapchat/src/index.ts:5
LOW secret-generic-credential packages/social/tiktok/src/index.ts:5
LOW secret-generic-credential packages/targets/plugin-vscode/src/index.test.ts:115
LOW secret-generic-credential packages/targets/registry-ans/src/index.test.ts:79
LOW secret-generic-credential packages/targets/registry-ans/src/index.ts:49
LOW secret-generic-credential packages/targets/sdk-pypi/src/index.test.ts:49

…and 3 more. Full results in the Security tab.

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 572c6fb into master Sep 26, 2026
8 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.

1 participant