Back to Blog
Web Development

Relation public.profiles does not exist - Supabase Error Fix

Discover how to troubleshoot the 'Database error saving new user', 'Failed to invite user' or 'relation public.profiles does not exist' error in Supabase with this step-by-step guide.

AK
Aysegul Karadan
5 min read
#supabase #nuxt3 #database #troubleshooting #postgresql #authentication

Troubleshooting the "Database error saving new user" in Supabase

Discover how to troubleshoot the 'Database error saving new user', 'Failed to invite user: failed to make invite request: Database error saving new user' or 'relation public.profiles does not exist supabase' error in Supabase. Our step-by-step guide helps you pinpoint the issue, review SQL code, and resolve conflicts. Perfect for developers looking to overcome this common challenge.

Step 1: Review Supabase Logs

To identify the cause of the error in Supabase, follow these steps:

  1. Log in to your Supabase account.
  2. Access the "Logs" section.
  3. Click on the "Auth" category.
  4. In the "Auth" logs, filter by "severity."
  5. Look for the error message related to the missing relation.

This step will help you pinpoint the specific error message and its context.

Common Error Message:

Error: 'relation public.profiles does not exist'

Step 2: Examine SQL Editor

Inspect your SQL code in the Supabase SQL editor to ensure your User Manager Starter code or any related queries for creating the "profiles" table are correct:

  1. Open the SQL editor in Supabase.
  2. Execute the SQL code responsible for creating the "profiles" table.
  3. Check for any warnings or errors.

If there are issues in your SQL code, this step will help you identify and address them.

Step 3: Delete Problematic Functions

In certain cases, functions or triggers might conflict with your database setup. If you've identified issues related to functions like handle_new_user or create trigger on_auth_user_created, consider deleting them:

Original Function and Trigger:

create function public.handle_new_user()
returns trigger as $$
begin
  insert into public.profiles (id, full_name, avatar_url)
  values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
  return new;
end;
$$ language plpgsql security definer;

create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.handle_new_user();

Solution: Drop the Function and Trigger

Run these queries to remove the conflicting function and trigger:

Drop the Function:

DROP FUNCTION IF EXISTS public.handle_new_user();

Drop the Trigger:

DROP TRIGGER IF EXISTS on_auth_user_created ON auth.users;

By removing conflicting functions and triggers, you can resolve potential conflicts and retest your database setup.

Step 4: Recreate the Profiles Table (If Needed)

If the profiles table doesn't exist, create it with the correct schema:

CREATE TABLE public.profiles (
  id UUID REFERENCES auth.users ON DELETE CASCADE,
  full_name TEXT,
  avatar_url TEXT,
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  PRIMARY KEY (id)
);

-- Enable Row Level Security
ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;

-- Create policies
CREATE POLICY "Public profiles are viewable by everyone."
  ON public.profiles FOR SELECT
  USING (true);

CREATE POLICY "Users can insert their own profile."
  ON public.profiles FOR INSERT
  WITH CHECK (auth.uid() = id);

CREATE POLICY "Users can update own profile."
  ON public.profiles FOR UPDATE
  USING (auth.uid() = id);

Step 5: Test User Creation

After completing the above steps:

  1. Try creating a new user through Supabase Auth
  2. Check if the profile is automatically created
  3. Verify that invite links are sent successfully

Result

After all these steps, I was able to:

✅ Create new users successfully
✅ Send invite links without errors
✅ Properly manage user profiles in Supabase

Key Takeaways

  1. Always check Supabase logs for detailed error messages
  2. Review SQL functions and triggers for conflicts
  3. Drop and recreate problematic functions when necessary
  4. Ensure the profiles table exists with correct schema
  5. Test thoroughly after making changes

Common Causes of This Error

  • Missing public.profiles table
  • Incorrect function or trigger syntax
  • Conflicting triggers on auth.users
  • Schema migration issues
  • Incorrect Row Level Security (RLS) policies

This guide also helps with:

  • Database error saving new user
  • Failed to invite user: failed to make invite request
  • relation "public.profiles" does not exist
  • function public.handle_new_user() does not exist

I hope this post will be helpful to you too.

Happy coding! 🚀

Additional Resources

Have you encountered similar Supabase errors? Share your experience in the comments below! 💬

AK

Aysegul Karadan

Content Creator at WonderCoder. Passionate about modern web development and sharing knowledge with the community.

Share this post

Help others discover this content

Enjoyed this post?

Check out more articles on our blog

View All Posts
WonderCoder Logo WonderCoder

⚡ Create. Explore. Evolve. Make Something New Every Day.

Connect

© 2026 WonderCoder. All rights reserved.