From 01850c2128f2f9889db352028d1c296247153ca5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 16 Jun 2019 17:15:36 +0200 Subject: [PATCH] Automatically recreate standard group after deletion to avoid violating foreign key constraints even if foreign key enforcing is disabled (SQLite's default behavior) Signed-off-by: DL6ER --- advanced/Templates/gravity.db.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/advanced/Templates/gravity.db.sql b/advanced/Templates/gravity.db.sql index e22cc44b..5fb9a5eb 100644 --- a/advanced/Templates/gravity.db.sql +++ b/advanced/Templates/gravity.db.sql @@ -7,6 +7,10 @@ CREATE TABLE domain_groups "description" TEXT ); INSERT INTO domain_groups ("id","description") VALUES (0,'Standard group'); +CREATE TRIGGER domain_groups_standard_group AFTER DELETE ON domain_groups WHEN OLD.id = 0 + BEGIN + INSERT INTO domain_groups ("id","description") VALUES (0,'Standard group'); + END; CREATE TABLE whitelist ( @@ -49,6 +53,10 @@ CREATE TABLE adlist_groups "description" TEXT ); INSERT INTO adlist_groups ("id","description") VALUES (0,'Standard group'); +CREATE TRIGGER adlist_groups_standard_group AFTER DELETE ON adlist_groups WHEN OLD.id = 0 + BEGIN + INSERT INTO adlist_groups ("id","description") VALUES (0,'Standard group'); + END; CREATE TABLE adlists (