Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On delete behaviour for tables #18

Open
3 tasks done
sueszli opened this issue Sep 7, 2022 · 3 comments
Open
3 tasks done

On delete behaviour for tables #18

sueszli opened this issue Sep 7, 2022 · 3 comments
Labels
backend enhancement New feature or request

Comments

@sueszli
Copy link
Member

sueszli commented Sep 7, 2022

By default Supabase, foreign keys have either RESTRICT or NO ACTION as on delete behaviour. This obviously doesn't work for most of our tables, but there is not way to change this except by dropping and reapplying these FK constraints manually.

Currently I have implemented the following:

  • cascade users -> profiles
  • cascade profiles -> event_registrations
  • cascade events -> event_registrations
  • set null storage.objects (header_images) -> events

We will have to do the following:

  • cascade profiles -> votes
  • cascade profiles -> event_user_pairs
  • cascade event_user_pairs -> votes

What should happen when the organizer of an event deletes their account? Do we just set the organizer null and cancel the event? Do we delete the event and try notifying the users? If we do not delete the event, do we delete parts that may include sensitive information about the organizer like the description?

Note that some tables' rows cannot be deleted by users at this point, but we should probably already start thinking about the expected behaviour, because it will making testing easier.

@sueszli sueszli added the backend label Sep 7, 2022
@sueszli
Copy link
Member Author

sueszli commented Sep 7, 2022

This is an interesting one.

I think we should add a button that enables the organizer to delete their event - then there wouldn't be a difference between cancelling and deleting the event.

After the deletion of an event the users just get notified that their event got cancelled and the mail contains the events title, description, address so they remember what it was.

@sueszli
Copy link
Member Author

sueszli commented Sep 7, 2022

After an event host deletes their account, all their thrown events get deleted aswell (but from the participants perspective the events were "cancelled")

@sueszli
Copy link
Member Author

sueszli commented Sep 7, 2022

This is because being notified about someone deleting their account makes it more likely that you delete yours aswell

@sueszli sueszli added the enhancement New feature or request label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant