diff options
author | DL6ER <dl6er@dl6er.de> | 2019-12-20 03:09:10 +0300 |
---|---|---|
committer | DL6ER <dl6er@dl6er.de> | 2019-12-20 03:09:10 +0300 |
commit | b32b5ad6e97044dd410d2717340631388bcb631b (patch) | |
tree | ed54b1d9c14ce0943cb2c9b45a28b629491de852 /advanced | |
parent | e2de199f4743b99c6bbb0eecedb66282203be638 (diff) |
Update gravity database to version 8. This enforces uniqueness on the group name.
Signed-off-by: DL6ER <dl6er@dl6er.de>
Diffstat (limited to 'advanced')
-rw-r--r-- | advanced/Scripts/database_migration/gravity-db.sh | 7 | ||||
-rw-r--r-- | advanced/Scripts/database_migration/gravity/7_to_8.sql | 23 |
2 files changed, 30 insertions, 0 deletions
diff --git a/advanced/Scripts/database_migration/gravity-db.sh b/advanced/Scripts/database_migration/gravity-db.sh index 28054643..6dc88bf3 100644 --- a/advanced/Scripts/database_migration/gravity-db.sh +++ b/advanced/Scripts/database_migration/gravity-db.sh @@ -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 } diff --git a/advanced/Scripts/database_migration/gravity/7_to_8.sql b/advanced/Scripts/database_migration/gravity/7_to_8.sql new file mode 100644 index 00000000..8f79bde8 --- /dev/null +++ b/advanced/Scripts/database_migration/gravity/7_to_8.sql @@ -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; |