1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-11-18 14:18:15 +00:00

Update gravity database to version 8. This enforces uniqueness on the group name.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-12-20 00:09:10 +00:00
parent e2de199f47
commit b32b5ad6e9
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
2 changed files with 30 additions and 0 deletions

View File

@ -72,4 +72,11 @@ upgrade_gravityDB(){
sqlite3 "${database}" < "${scriptPath}/6_to_7.sql"
version=7
fi
if [[ "$version" == "7" ]]; then
# This migration script recreated the group table
# to ensure uniqueness on the group name
echo -e " ${INFO} Upgrading gravity database from version 7 to 8"
sqlite3 "${database}" < "${scriptPath}/7_to_8.sql"
version=7
fi
}

View File

@ -0,0 +1,23 @@
.timeout 30000
PRAGMA FOREIGN_KEYS=OFF;
BEGIN TRANSACTION;
ALTER TABLE "group" RENAME TO "group__";
CREATE TABLE "group"
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
enabled BOOLEAN NOT NULL DEFAULT 1,
name TEXT UNIQUE NOT NULL,
description TEXT
);
INSERT OR IGNORE INTO "group" SELECT * FROM "group__";
DROP TABLE "group__";
UPDATE info SET value = 8 WHERE property = 'version';
COMMIT;