mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 12:40:56 +00:00
Merge pull request #2944 from pi-hole/fix/vw_gravity_creation_v1
Fix gravity database table creation order
This commit is contained in:
commit
d244a018d0
@ -22,6 +22,7 @@ upgrade_gravityDB(){
|
|||||||
if [[ "$version" == "1" ]]; then
|
if [[ "$version" == "1" ]]; then
|
||||||
# This migration script upgrades the gravity.db file by
|
# This migration script upgrades the gravity.db file by
|
||||||
# adding the domain_audit table
|
# adding the domain_audit table
|
||||||
|
echo -e " ${INFO} Upgrading gravity database from version 1 to 2"
|
||||||
sqlite3 "${database}" < "/etc/.pihole/advanced/Scripts/database_migration/gravity/1_to_2.sql"
|
sqlite3 "${database}" < "/etc/.pihole/advanced/Scripts/database_migration/gravity/1_to_2.sql"
|
||||||
version=2
|
version=2
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ upgrade_gravityDB(){
|
|||||||
# This migration script upgrades the gravity.db file by
|
# This migration script upgrades the gravity.db file by
|
||||||
# renaming the regex table to regex_blacklist, and
|
# renaming the regex table to regex_blacklist, and
|
||||||
# creating a new regex_whitelist table + corresponding linking table and views
|
# creating a new regex_whitelist table + corresponding linking table and views
|
||||||
|
echo -e " ${INFO} Upgrading gravity database from version 2 to 3"
|
||||||
sqlite3 "${database}" < "/etc/.pihole/advanced/Scripts/database_migration/gravity/2_to_3.sql"
|
sqlite3 "${database}" < "/etc/.pihole/advanced/Scripts/database_migration/gravity/2_to_3.sql"
|
||||||
version=3
|
version=3
|
||||||
fi
|
fi
|
||||||
|
@ -89,10 +89,6 @@ CREATE TABLE info
|
|||||||
|
|
||||||
INSERT INTO info VALUES("version","1");
|
INSERT INTO info VALUES("version","1");
|
||||||
|
|
||||||
CREATE VIEW vw_gravity AS SELECT domain
|
|
||||||
FROM gravity
|
|
||||||
WHERE domain NOT IN (SELECT domain from vw_whitelist);
|
|
||||||
|
|
||||||
CREATE VIEW vw_whitelist AS SELECT DISTINCT domain
|
CREATE VIEW vw_whitelist AS SELECT DISTINCT domain
|
||||||
FROM whitelist
|
FROM whitelist
|
||||||
LEFT JOIN whitelist_by_group ON whitelist_by_group.whitelist_id = whitelist.id
|
LEFT JOIN whitelist_by_group ON whitelist_by_group.whitelist_id = whitelist.id
|
||||||
@ -141,3 +137,6 @@ CREATE TRIGGER tr_adlist_update AFTER UPDATE ON adlist
|
|||||||
UPDATE adlist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE address = NEW.address;
|
UPDATE adlist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE address = NEW.address;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
CREATE VIEW vw_gravity AS SELECT domain
|
||||||
|
FROM gravity
|
||||||
|
WHERE domain NOT IN (SELECT domain from vw_whitelist);
|
||||||
|
Loading…
Reference in New Issue
Block a user