Skip to content

fix(auth): add profiles.email so signup trigger succeeds (#388) - #408

Closed
mutabalShawandar wants to merge 1 commit into
TheVicky1:mainfrom
mutabalShawandar:fix/388-profiles-email-column
Closed

mutabalShawandar wants to merge 1 commit into
TheVicky1:mainfrom
mutabalShawandar:fix/388-profiles-email-column

Conversation

@mutabalShawandar

Copy link
Copy Markdown
Contributor

1. Related Issue

Fixes #388

2. Summary of Changes

Registering a new account fails with Database error saving new user (HTTP 500). The on_auth_user_created trigger calls handle_new_user(), which 20260911050000_user_onboarding.sql redefines to insert into public.profiles (id, email, full_name, timezone, onboarding_status, ...). The profiles table (20260906000000_create_profiles_table.sql) has no email column, and no migration adds one, so the insert fails and the signup is rolled back.

This PR adds a new migration, 20260918000000_add_profiles_email.sql, that:

  • adds profiles.email (ADD COLUMN IF NOT EXISTS email TEXT)
  • backfills existing rows from auth.users where email is NULL

3. Motivation & Context

New users cannot register on a database built from supabase/migrations/. The UI only shows the generic "Registration failed" message because signUpAction swallows the underlying error.

4. Implementation Details

5. Testing & Local Validation

  • npm run lint not run (SQL-only change)
  • npx tsc --noEmit not run (SQL-only change)
  • npm test not run (SQL-only change)
  • node scratch/secret-scan.mjs found 0 secrets
  • npm run build not run (SQL-only change)

Manual verification: applied all migrations on a fresh local Supabase instance (with the #387 fix) and registered a new account. Signup succeeded and a profiles row was created with the email populated.

7. Database & Security Impact

  • Database modifications included
    • Sequential migration added in supabase/migrations/
    • No RLS changes
    • No destructive schema changes

handle_new_user() inserts into profiles.email, but no migration created the
column, causing 'Database error saving new user' on signup. Add it in a new
migration (without editing applied ones) and backfill from auth.users.

Fixes TheVicky1#388
@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Vicky's projects Team on Vercel.

A member of the Team first needs to authorize it.

@TheVicky1 TheVicky1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It didn't passed all the Test Cases. Kindly go through it once and check it again.

I am closing this PR you can raise a new one with the correct code.

Thanks!

@TheVicky1 TheVicky1 closed this Oct 6, 2026
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.

fix: signup fails with "Database error saving new user"

2 participants