2020-01-24 17:39:13 +00:00
|
|
|
.timeout 30000
|
|
|
|
|
|
|
|
ATTACH DATABASE '/etc/pihole/gravity.db' AS OLD;
|
|
|
|
|
|
|
|
BEGIN TRANSACTION;
|
|
|
|
|
2020-01-27 10:12:05 +00:00
|
|
|
DROP TRIGGER tr_domainlist_add;
|
|
|
|
DROP TRIGGER tr_client_add;
|
|
|
|
DROP TRIGGER tr_adlist_add;
|
|
|
|
|
2020-01-24 17:39:13 +00:00
|
|
|
INSERT OR REPLACE INTO "group" SELECT * FROM OLD."group";
|
|
|
|
|
|
|
|
INSERT OR REPLACE INTO domainlist SELECT * FROM OLD.domainlist;
|
2022-01-30 20:09:24 +00:00
|
|
|
DELETE FROM OLD.domainlist_by_group WHERE domainlist_id NOT IN (SELECT id FROM OLD.domainlist);
|
2020-01-24 17:39:13 +00:00
|
|
|
INSERT OR REPLACE INTO domainlist_by_group SELECT * FROM OLD.domainlist_by_group;
|
|
|
|
|
|
|
|
INSERT OR REPLACE INTO adlist SELECT * FROM OLD.adlist;
|
2022-01-30 20:09:24 +00:00
|
|
|
DELETE FROM OLD.adlist_by_group WHERE adlist_id NOT IN (SELECT id FROM OLD.adlist);
|
2020-01-24 17:39:13 +00:00
|
|
|
INSERT OR REPLACE INTO adlist_by_group SELECT * FROM OLD.adlist_by_group;
|
|
|
|
|
|
|
|
INSERT OR REPLACE INTO client SELECT * FROM OLD.client;
|
2022-01-30 20:09:24 +00:00
|
|
|
DELETE FROM OLD.client_by_group WHERE client_id NOT IN (SELECT id FROM OLD.client);
|
2020-01-24 17:39:13 +00:00
|
|
|
INSERT OR REPLACE INTO client_by_group SELECT * FROM OLD.client_by_group;
|
|
|
|
|
2020-01-27 10:12:05 +00:00
|
|
|
|
|
|
|
CREATE TRIGGER tr_domainlist_add AFTER INSERT ON domainlist
|
|
|
|
BEGIN
|
|
|
|
INSERT INTO domainlist_by_group (domainlist_id, group_id) VALUES (NEW.id, 0);
|
|
|
|
END;
|
|
|
|
|
|
|
|
CREATE TRIGGER tr_client_add AFTER INSERT ON client
|
|
|
|
BEGIN
|
|
|
|
INSERT INTO client_by_group (client_id, group_id) VALUES (NEW.id, 0);
|
|
|
|
END;
|
|
|
|
|
|
|
|
CREATE TRIGGER tr_adlist_add AFTER INSERT ON adlist
|
|
|
|
BEGIN
|
|
|
|
INSERT INTO adlist_by_group (adlist_id, group_id) VALUES (NEW.id, 0);
|
|
|
|
END;
|
|
|
|
|
|
|
|
|
2020-01-24 17:39:13 +00:00
|
|
|
COMMIT;
|