From 014e675dba0f6e5f4f02e99e08e83fda79a07809 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 17 Mar 2026 13:42:21 -0700 Subject: [PATCH] schema: add ON DELETE CASCADE to snapshot_files.file_id and snapshot_blobs.blob_id FKs closes https://git.eeqj.de/sneak/vaultik/issues/19 --- 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 64b03a0..26fbf8c 100644 --- a/internal/database/schema.sql +++ b/internal/database/schema.sql @@ -103,7 +103,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) @@ -116,7 +116,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)