From 5993ea8f6fd4316aee313e1e6fdae2dc7fbab5df Mon Sep 17 00:00:00 2001
From: Akshay Nair <phenax5@gmail.com>
Date: Wed, 3 Jun 2026 12:49:35 +0530
Subject: Add circle example

---
 setup.sql | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'setup.sql')

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;
-- 
cgit v1.3.1

