From 5bb79de70b73662e03772564f5f242b216f85bf5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 30 Jan 2022 10:38:24 +0100 Subject: [PATCH] Clean possible leftovers in domainlist_by_group, adlist_by_group, and client_by_group before copying from database base to avoid foreign key violations. Signed-off-by: DL6ER --- advanced/Templates/gravity_copy.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/advanced/Templates/gravity_copy.sql b/advanced/Templates/gravity_copy.sql index 4a2a9b22..a927dd8d 100644 --- a/advanced/Templates/gravity_copy.sql +++ b/advanced/Templates/gravity_copy.sql @@ -12,14 +12,17 @@ INSERT OR REPLACE INTO "group" SELECT * FROM OLD."group"; INSERT OR REPLACE INTO domain_audit SELECT * FROM OLD.domain_audit; INSERT OR REPLACE INTO domainlist SELECT * FROM OLD.domainlist; +DELETE FROM domainlist_by_group WHERE domainlist_id NOT IN (SELECT id FROM domainlist); INSERT OR REPLACE INTO domainlist_by_group SELECT * FROM OLD.domainlist_by_group; INSERT OR REPLACE INTO adlist SELECT * FROM OLD.adlist; +DELETE FROM adlist_by_group WHERE adlist_id NOT IN (SELECT id FROM adlist); INSERT OR REPLACE INTO adlist_by_group SELECT * FROM OLD.adlist_by_group; INSERT OR REPLACE INTO info SELECT * FROM OLD.info; INSERT OR REPLACE INTO client SELECT * FROM OLD.client; +DELETE FROM client_by_group WHERE client_id NOT IN (SELECT id FROM client); INSERT OR REPLACE INTO client_by_group SELECT * FROM OLD.client_by_group;