Hi everyone - following up on an issue from last n...
# off-topic
j
Hi everyone - following up on an issue from last night. When trying to delete a user from the dashboard, I received a fk error. I had deleted all tables with constraints. But the error persisted. A user mentioned the error was on the objects table, so that pointed me to the storage I had set up. Deleting all of the images in a bucket that I uploaded with the user allowed me to delete the user. I'd like to remove this restriction, but I'm not sure how, or why it exists in the first place.
j
oh sorry i didnt see this, dont come by that often
i've never used buckets before, but a wild guess might be that there's an underlying
objects
table that is created automatically when you create a bucket. this table has a foreign key
owner
that links it to the users table. because of this constraint, postgres might not allow you to delete the user without first deleting all the user's objects
one solution might be to recreate this
owner
foreign key, with an
ON DELETE CASCADE
constraint (https://www.postgresql.org/docs/current/ddl-constraints.html), so that deleting a user will automatically delete the user's objects
yeah a quick look at https://supabase.io/docs/guides/storage#allow-public-access-to-a-bucket shows that there's an
objects
table inside the
storage
schema by default
just tagging you so you'll be notified here: @User
j
@User thank you for this.
I opened an issue and found a resolution - it is exactly as you pointed out. I added an on delete set null