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

Consider how to handle cascading deletes #661

Open
brassy-endomorph opened this issue Oct 8, 2024 · 0 comments
Open

Consider how to handle cascading deletes #661

brassy-endomorph opened this issue Oct 8, 2024 · 0 comments

Comments

@brassy-endomorph
Copy link
Collaborator

brassy-endomorph commented Oct 8, 2024

Is your feature request related to a problem? Please describe.

We have database rows related via foreign keys. In the future they may also correspond to external objects (files, S3 objects). If a user deletes their account, we need to delete related files. Thus, making deletes cascade may leave objects behind.

Describe the solution you'd like

Four possible solutions:

  1. Add ON DELETE CASCADE to the model so this logic is applied to the DB
  2. Add cascade="all,delete,delete-orphan" to the ORM only so that deleting rows via Python (but not direct DML) cascades
  3. Use 1 or 2 on rows that have no external objects and do manual deletes on rows with external objects
  4. Always do it explicitly

I'm leaning toward 1+3 in that having cascade logic applied to FKs is senseible but that we want to have a worker queue model for when a user deletes an account with 5000 messages each its own external file in S3. This would support offline deletes in cases where a delete would time out an HTTP request.

Blocks (or at least strongly influences) #474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant