mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Add a new migration script to fix the previous one
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
62ec7de963
commit
c944f6a320
@ -80,4 +80,11 @@ upgrade_gravityDB(){
|
||||
sqlite3 "${database}" < "${scriptPath}/7_to_8.sql"
|
||||
version=8
|
||||
fi
|
||||
if [[ "$version" == "8" ]]; then
|
||||
# This migration fixes some issues that were introduced
|
||||
# in the previous migration script.
|
||||
echo -e " ${INFO} Upgrading gravity database from version 8 to 9"
|
||||
sqlite3 "${database}" < "${scriptPath}/8_to_9.sql"
|
||||
version=9
|
||||
fi
|
||||
}
|
||||
|
26
advanced/Scripts/database_migration/gravity/8_to_9.sql
Normal file
26
advanced/Scripts/database_migration/gravity/8_to_9.sql
Normal file
@ -0,0 +1,26 @@
|
||||
.timeout 30000
|
||||
|
||||
PRAGMA FOREIGN_KEYS=OFF;
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
DROP TRIGGER IF EXISTS tr_group_update;
|
||||
DROP TRIGGER IF EXISTS tr_group_zero;
|
||||
|
||||
PRAGMA legacy_alter_table=ON;
|
||||
ALTER TABLE "group" RENAME TO "group__";
|
||||
PRAGMA legacy_alter_table=OFF;
|
||||
ALTER TABLE "group__" RENAME TO "group";
|
||||
|
||||
CREATE TRIGGER tr_group_update AFTER UPDATE ON "group"
|
||||
BEGIN
|
||||
UPDATE "group" SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE id = NEW.id;
|
||||
END;
|
||||
|
||||
CREATE TRIGGER tr_group_zero AFTER DELETE ON "group"
|
||||
BEGIN
|
||||
INSERT OR IGNORE INTO "group" (id,enabled,name) VALUES (0,1,'Unassociated');
|
||||
END;
|
||||
|
||||
|
||||
COMMIT;
|
Loading…
Reference in New Issue
Block a user