fix(db): cascade soft-delete tasks and events on session delete#2207
Open
mesutoezdil wants to merge 2 commits into
Open
fix(db): cascade soft-delete tasks and events on session delete#2207mesutoezdil wants to merge 2 commits into
mesutoezdil wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Postgres deletion path for sessions so that removing a session also cleans up related data, instead of leaving orphaned task/event/share rows.
Changes:
- Add sqlc queries to soft-delete all tasks and events for a session.
- Add a sqlc query to hard-delete all session shares for a session.
- Wrap
DeleteSessionin a transaction to execute the cascade cleanup and then soft-delete the session row.
Reviewed changes
Copilot reviewed 4 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| go/core/internal/database/queries/tasks.sql | Adds SoftDeleteTasksBySession SQL query. |
| go/core/internal/database/queries/session_shares.sql | Adds DeleteSessionSharesBySession SQL query. |
| go/core/internal/database/queries/events.sql | Adds SoftDeleteEventsBySession SQL query. |
| go/core/internal/database/gen/tasks.sql.go | Adds generated Go method for SoftDeleteTasksBySession. |
| go/core/internal/database/gen/session_shares.sql.go | Adds generated Go method for DeleteSessionSharesBySession. |
| go/core/internal/database/gen/querier.go | Extends the sqlc Querier interface with the new methods. |
| go/core/internal/database/gen/events.sql.go | Adds generated Go method for SoftDeleteEventsBySession. |
| go/core/internal/database/client_postgres.go | Wraps DeleteSession in a transaction and invokes the new cascade operations. |
Files not reviewed (4)
- go/core/internal/database/gen/events.sql.go: Generated file
- go/core/internal/database/gen/querier.go: Generated file
- go/core/internal/database/gen/session_shares.sql.go: Generated file
- go/core/internal/database/gen/tasks.sql.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mesutoezdil
force-pushed
the
fix/delete-session-cascade
branch
8 times, most recently
from
July 14, 2026 13:48
97b57fb to
96d6214
Compare
EItanya
reviewed
Jul 14, 2026
mesutoezdil
force-pushed
the
fix/delete-session-cascade
branch
3 times, most recently
from
July 15, 2026 19:01
0a8b943 to
d587361
Compare
Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
mesutoezdil
force-pushed
the
fix/delete-session-cascade
branch
from
July 15, 2026 20:06
d587361 to
7239ff3
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
deleting a session left related task, event, and session_share rows untouched. this wraps DeleteSession in a transaction that soft-deletes tasks and events and hard-deletes session shares before marking the session itself as deleted.