Closed rohankm closed 7 months ago
Hey @rohankm. Can I see the table schema for user_details
?
Hey @rohankm. Can I see the table schema for
user_details
?
Hi, here is the schema
create table
public.user_details (
id uuid not null,
created_at timestamp without time zone not null default now(),
updated_at timestamp without time zone not null default now(),
email text not null,
photo_uri text null default ''::text,
name text null default ''::text,
constraint user_details_pkey primary key (id),
constraint user_details_id_fkey foreign key (id) references auth.users (id) on delete cascade
) tablespace pg_default;
basically, the id of the table is automatically filled from auth.uid()
function
Ahhhh if it has a default of auth.uid()
, Supawright can't handle it because it uses the service account, which has a auth.uid()
of null
.
Take a look at #4 for a solution :)
Thanks createUser
works
btw does the trigger not work while creating user?
i have set up a trigger when a user sign ups it automatically creates a record in user_details
Does it require any special fields in the metadata etc.? The trigger should still work if it's set up correctly - we use triggers on auth.users
inserts too, and it works fine.
no, it just takes the user ID and email and creates a row in user_details
.
When I manually sign up the trigger works
I tried to select and it returned no rows
{ data: [] }
I can't see any reason it wouldn't work. Is the auth.users
record being created successfully?
The createUser
function just calls the Supabase sign up function under the hood:
public async createUser(attributes?: AdminUserAttributes): Promise<User> {
const { data, error } = await this.supabase().auth.admin.createUser({
email: faker.internet.email(),
password: faker.internet.password(),
...attributes
})
if (error) {
log.error('Error creating user', { error, attributes })
throw new Error('Error creating user: ' + error.message)
}
this.record({
schema: 'auth',
table: 'users',
data: data.user as unknown as Select<Database, 'auth', 'users'>
})
return data.user
}
Can I see the code for your trigger?
Closing due to inactivity
Hi, In my user_details table, the id is one to one relation with auth.users.id.
when i try to run the test
i get
Error: Error inserting data into user_details: insert or update on table "user_details" violates foreign key constraint "user_details_id_fkey"
How do i fix this?