-
Notifications
You must be signed in to change notification settings - Fork 7
Add soft delete #468
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?
Add soft delete #468
Conversation
.prepare("SELECT owner_id, created_at FROM notebooks WHERE id = ?") | ||
.prepare( | ||
"SELECT owner_id, created_at FROM notebooks WHERE id = ? AND deleted_at IS NULL" | ||
) | ||
.bind(notebookId) | ||
.first<{ owner_id: string; created_at: string }>(); |
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.
If we're listing permissions on this particular notebook, I feel like we don't have to do the delete check. That's metadata to worry about when choosing whether or not to show it in the notebook dashboard.
.prepare("SELECT 1 FROM notebooks WHERE id = ? AND owner_id = ?") | ||
.prepare( | ||
"SELECT 1 FROM notebooks WHERE id = ? AND owner_id = ? AND 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.
Same for this one. Someone can still own a deleted notebook.
@@ -378,7 +378,7 @@ export const appRouter = router({ | |||
} | |||
}), | |||
|
|||
// Delete notebook | |||
// Delete notebook (soft delete) | |||
deleteNotebook: authedProcedure |
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.
Could probably call this softDeleteNotebook
now, so that someday when we bring in real delete that has a way to go.
WHERE user_id = ? AND permission = 'writer' AND notebook_id IN (${placeholders})` | ||
`SELECT np.notebook_id FROM notebook_permissions np | ||
INNER JOIN notebooks n ON np.notebook_id = n.id | ||
WHERE np.user_id = ? AND np.permission = 'writer' AND n.deleted_at IS NULL AND np.notebook_id IN (${placeholders})` |
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.
I do think the deleted_at
check goes outside of the permissions provider.
ai-generated soft delete