Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: improve the example of using triggers in user data management (#19288)

Greg Wolanski146b6321a916
diff --git a/apps/docs/pages/guides/auth/managing-user-data.mdx b/apps/docs/pages/guides/auth/managing-user-data.mdx
index 74b3c428575..0fd689249a5 100644
--- a/apps/docs/pages/guides/auth/managing-user-data.mdx
+++ b/apps/docs/pages/guides/auth/managing-user-data.mdx
@@ -214,7 +214,7 @@ val metadata = user?.userMetadata
If you want to add a row to your `public.profiles` table every time a user signs up, you can use triggers.
If the trigger fails however, it could block the user sign ups - so make sure that the code is well-tested.
-For example:
+Example:
```sql
-- inserts a row into public.profiles
@@ -224,8 +224,8 @@ language plpgsql
security definer set search_path = public
as $$
begin
- insert into public.profiles (id)
- values (new.id);
+ insert into public.profiles (id, first_name, age)
+ values (new.id, new.raw_user_meta_data ->> 'first_name', new.raw_user_meta_data['age']::integer);
return new;
end;
$$;