-
-
Notifications
You must be signed in to change notification settings - Fork 204
Closed
Description
Bug report
Describe the bug
When a user uploads an object to a bucket, the object's row in storage.objects
has a column owner
that has a FK constraint objects_owner_fkey
to auth.users.id
. However, it's not set up with on delete {cascade|set null}
—which prevents the user from actually being deleted.
Attempting to delete a user with a storage.object
referencing the user results in a FK constraint violation.
To Reproduce
- Create a user
- Authenticate as that user on the client
- Upload an object as that user on the client
- Delete that user via dashboard
- You'll get a FK constraint violation error:
Deleting user failed: update or delete on table "users" violates foreign key constraint "objects_owner_fkey" on table "objects"
Expected behavior
Should be able to delete user whilst retaining the object in the database.
Suggested fix & temporary workaround
Add on delete set null
to the objects_owner_fkey
constraint:
alter table storage.objects
drop constraint objects_owner_fkey,
add constraint objects_owner_fkey
foreign key (owner)
references auth.users(id)
on delete set null;
RyuNIshimura, WarrenBuffering, MuhammedKpln, bennik88, tanoabeleyra and 17 morecodingcaffeine and afg2002codingcaffeine and alexrabinmhaidarhanif, MaybeTri and 9jorgeLuis
Metadata
Metadata
Assignees
Labels
No labels