-
Notifications
You must be signed in to change notification settings - Fork 652
fix(db): cascade soft-delete tasks and events on session delete #2207
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| DROP INDEX IF EXISTS session_id_active_unique; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- A session's client-supplied id was only unique per (id, user_id), so two | ||
| -- different users could create sessions with the same id. Deleting one then | ||
| -- cascaded to the other user's tasks and events, which are keyed by session_id | ||
| -- alone. This index makes id unique among live sessions so that can't happen. | ||
| CREATE UNIQUE INDEX IF NOT EXISTS session_id_active_unique ON session (id) WHERE deleted_at IS NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we're not using CASCADE deletes via SQL for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no fk exists between session and task/event/session_share right now
even if it did, tasks and events r soft deleted, and ON DELETE CASCADE only fires on a real DELETE and not an UPDATE.
and session itself is soft deleted too, so cascade would never trigger
that's why this is explicit app code instead.