From 15f0172e0c491c544f94f1f8012c902e4b3f998b Mon Sep 17 00:00:00 2001 From: user Date: Thu, 19 Mar 2026 06:15:40 -0700 Subject: [PATCH] fix: restore ON DELETE CASCADE on snapshot_files.file_id and snapshot_blobs.blob_id FKs --- internal/database/schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/database/schema.sql b/internal/database/schema.sql index 2bc2254..cdc8533 100644 --- a/internal/database/schema.sql +++ b/internal/database/schema.sql @@ -102,7 +102,7 @@ CREATE TABLE IF NOT EXISTS snapshot_files ( file_id TEXT NOT NULL, PRIMARY KEY (snapshot_id, file_id), FOREIGN KEY (snapshot_id) REFERENCES snapshots(id) ON DELETE CASCADE, - FOREIGN KEY (file_id) REFERENCES files(id) + FOREIGN KEY (file_id) REFERENCES files(id) ON DELETE CASCADE ); -- Index for efficient file lookups (used in orphan detection) @@ -115,7 +115,7 @@ CREATE TABLE IF NOT EXISTS snapshot_blobs ( blob_hash TEXT NOT NULL, PRIMARY KEY (snapshot_id, blob_id), FOREIGN KEY (snapshot_id) REFERENCES snapshots(id) ON DELETE CASCADE, - FOREIGN KEY (blob_id) REFERENCES blobs(id) + FOREIGN KEY (blob_id) REFERENCES blobs(id) ON DELETE CASCADE ); -- Index for efficient blob lookups (used in orphan detection)