syncWithRemote deletes snapshot records without cleaning up related tables #10
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In
snapshot.gosyncWithRemote(), local snapshots not found in remote are deleted with just:This only deletes the
snapshotsrow. Thesnapshot_files,snapshot_blobs, anduploadsrows are NOT deleted first. Depending on FK constraints, this may either fail (FK violation) or leave orphaned records.Compare with
ListSnapshots()which correctly deletes related records first, anddeleteSnapshotFromLocalDB()which also handles this.Ref: parent issue #1
Closing: this is no longer an issue. PR #44 and PR #46 added
ON DELETE CASCADEto all relevant FKs, and FK enforcement is enabled (PRAGMA foreign_keys = ON). Deleting a snapshot row now automatically cascades to delete relatedsnapshot_files,snapshot_blobs, anduploadsrows. The explicit cleanup indeleteSnapshotFromLocalDB()is redundant belt-and-suspenders. sneak closed PR #47 as unnecessary for the same reason.