i can't understand how relationships are supposed ...
# help
m
i can't understand how relationships are supposed to work. how do i make a table rows reference user? i can't make foregin key because it requires to be unique, but it cannot be unique in my case
my problem is that i am trying to reference user's identity but it cannot be referenced. sure i can reference user.id but i want to pull user's oauth profile
which already is saved in auth.identities
even if i set it as unique,
or is it simply not possible to reference identities?
t
bio column is signed like primary?
m
bio doesnt exist, i cannot even create column that references identities
i found some info on github that identities are accessible only to logged in users so cannot even be accessed by 3rd party users, but i had no idea that supabase would lock it from itself
t
oh yes
sorry I saw now
u are wrong the way
I explain, the user_id column into identities is a text field not uuid
m
i didnt set type, it was autofilled
t
if you want make a foreign key using uuid type then u have to use auth.users.id
bio -type: uuid foreign key on auth.users.id
m
yeah but i dont want to reference user.id
i need identities info
like github username and avatar
for example
that info is available in auth.identities
but it cannot be referenced
t
inside the table where u are trying to make the column bio do you have already some rows?
m
nope
im creating new table
t
ok the error is the primary option on id
m
but if i do same on new column, its same error
t
you have to disable the primary option if you want the id column has foreign key
m
and also that
t
personally I don't make it on creation table, usually I made the table with columns I need and then I set the foreign keys
m
i had no luck on existing tables either
guess i will go different route - create profile, trigger function on insert, call api, fetch info, save to profile table. but imo there really should be a way to reference identities
but this can be closed~