-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Labels
adaptersChanges related to the core code concerning database adaptersChanges related to the core code concerning database adaptersdocsRelates to documentationRelates to documentationhelp-neededThe maintainer needs help due to time constraint/missing knowledgeThe maintainer needs help due to time constraint/missing knowledgesupabase@auth/supabase-adapter@auth/supabase-adaptertriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Description
What is the improvement or update you wish to see?
- Create client accroding to the supabase adapter docs like this:
const { supabaseAccessToken } = session;
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
{
global: {
headers: {
Authorization: `Bearer ${supabaseAccessToken}`,
},
},
}
);
- Then using this client to perform supabase storage upload will result in error: parent resource cannot be found. Supabase postgres log shows this error actually is:
insert or update on table "objects" violates foreign key constraint "objects_owner_fkey
If you look at the storage objects table definition will find following
constraint objects_owner_fkey foreign key (owner) references auth.users (id)
-
Possible cause of the problem: next_auth schema is created and used in order to implement next auth instead of the default auth schema.
-
Possible workaround:
alter table storage.objects
drop constraint objects_owner_fkey,
add constraint objects_owner_fkey
foreign key (owner)
references next_auth.users(id)
after this sql action, above supabase client works with storage upload, and next_auth.user(id) is loaded into the "owner" column of the objects table upon upload action.
- Is it a good idea to mention the inconsistency and possible official solution in the supabase adapter documentation?
Is there any context that might help us understand?
related issue from supabase:
"Storage.objects table should not use fk constraint with owners column on auth.users id column "
supabase/storage#276
Does the docs page already exist? Please link to it.
Metadata
Metadata
Assignees
Labels
adaptersChanges related to the core code concerning database adaptersChanges related to the core code concerning database adaptersdocsRelates to documentationRelates to documentationhelp-neededThe maintainer needs help due to time constraint/missing knowledgeThe maintainer needs help due to time constraint/missing knowledgesupabase@auth/supabase-adapter@auth/supabase-adaptertriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.