create profile for new user trigger
# help-and-questions
r
This is my first time messing with triggers and functions, I wanted to have in my profiles table additional information that the user provide in the registration form, so I copied a simple function and created a trigger on auth after insert, "begin insert into public.profiles (id) values (new.id); return new; end;" But I'm getting an error: "failed to close prepared statement: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02): ERROR: column \"id\" is of type bigint but expression is of type uuid (SQLSTATE 42804)" Shouldn't new.id be of the correct type already? This line is copied from https://supabase.com/docs/guides/auth/managing-user-data so it should work, similar line works in another project I've seen and no one is getting such an error. I must've skipped an important step I guess? I cant fix it and I'd be very thankful for providing any direction in solving this problem.
g
Is your profile id column bigint or UUID?
r
int8
g
And user id is UUID
r
Yes
g
That is your error
Your id column in profiles has to match the type coming from auth.users, which is UUID
OR at least you need a column in profiles that is UUID like user_id to write that to.
From the guide you linked.

https://cdn.discordapp.com/attachments/1111275647826939914/1111282400790593618/image.png

r
Thank you for answering already, but I can't change id table type, I'm getting failed to update pg.columns with the given ID: cannot cast type bigint to uuid even though the the whole profiles table is empty
Should I just delete original profiles and create it from scratch?
g
Yeah postgres won't change bigint to uuid even empty. Or you can have a new column be the UUID column and still have an int primary key.
r
Allright, thank you very much for your time helping me, I really appreciate it
8 Views