aboutsummaryrefslogtreecommitdiff
path: root/setup.sql
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-06-03 12:49:35 +0530
committerAkshay Nair <phenax5@gmail.com>2026-06-03 12:49:35 +0530
commit5993ea8f6fd4316aee313e1e6fdae2dc7fbab5df (patch)
treea71b605a3e6d53158ca866fb30c76a0d0601357f /setup.sql
parent8c62edb87433bd0ac93fdef4585582990513236b (diff)
downloadsqlite-creative-coding-5993ea8f6fd4316aee313e1e6fdae2dc7fbab5df.tar.gz
sqlite-creative-coding-5993ea8f6fd4316aee313e1e6fdae2dc7fbab5df.zip
Add circle example
Diffstat (limited to '')
-rw-r--r--setup.sql7
1 files changed, 7 insertions, 0 deletions
diff --git a/setup.sql b/setup.sql
index d5d8ce2..7b6732e 100644
--- a/setup.sql
+++ b/setup.sql
@@ -18,3 +18,10 @@ CREATE TABLE pixels (
FOREIGN KEY(image_id) REFERENCES images(id),
UNIQUE(image_id, x, y)
);
+
+CREATE TRIGGER delete_pixels_when_image_deleted
+AFTER DELETE ON images
+WHEN (SELECT COUNT(*) FROM images WHERE id = OLD.id) = 0
+BEGIN
+ DELETE FROM pixels WHERE image_id = OLD.id;
+END;