uploads table FK on snapshot_id lacks ON DELETE CASCADE #18

Closed
opened 2026-02-08 17:16:54 +01:00 by clawbot · 0 comments
Collaborator

In schema.sql, the uploads table has:

FOREIGN KEY (snapshot_id) REFERENCES snapshots(id)

Unlike snapshot_files and snapshot_blobs which have ON DELETE CASCADE, the uploads FK does not cascade. This means deleting a snapshot without first deleting its uploads will fail with a FK violation (if FK enforcement is on). The code works around this by manually deleting uploads first in deleteSnapshotFromLocalDB, but syncWithRemote does NOT do this cleanup.

Ref: parent issue #1

In `schema.sql`, the `uploads` table has: ```sql FOREIGN KEY (snapshot_id) REFERENCES snapshots(id) ``` Unlike `snapshot_files` and `snapshot_blobs` which have `ON DELETE CASCADE`, the `uploads` FK does not cascade. This means deleting a snapshot without first deleting its uploads will fail with a FK violation (if FK enforcement is on). The code works around this by manually deleting uploads first in `deleteSnapshotFromLocalDB`, but `syncWithRemote` does NOT do this cleanup. Ref: parent issue #1
clawbot self-assigned this 2026-02-20 09:29:00 +01:00
clawbot added the needs-review label 2026-02-20 09:29:00 +01:00
sneak closed this issue 2026-03-19 13:59:29 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/vaultik#18