From bbd55263df0f3fe8158f88735e2542da42a2d2ea Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:09:06 +0200 Subject: [PATCH] Update configuration DB This prevents a lockout scenario where the root user may be left without permissions if the DB was created prior to this PR. --- core/include/db_manager.h | 2 +- core/src/db_manager.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/include/db_manager.h b/core/include/db_manager.h index 67f0f1d..3f0fdbe 100644 --- a/core/include/db_manager.h +++ b/core/include/db_manager.h @@ -18,7 +18,7 @@ #ifndef BAN_MANAGER_H #define BAN_MANAGER_H -#define DB_VERSION 1 +#define DB_VERSION 2 #include #include diff --git a/core/src/db_manager.cpp b/core/src/db_manager.cpp index afae5b1..34aec81 100644 --- a/core/src/db_manager.cpp +++ b/core/src/db_manager.cpp @@ -399,6 +399,10 @@ void DBManager::updateDB(int current_version) QSqlQuery("ALTER TABLE bans ADD COLUMN MODERATOR TEXT"); Q_FALLTHROUGH(); case 1: + QSqlQuery("PRAGMA user_version = " + QString::number(1)); + Q_FALLTHROUGH(); + case 2: + QSqlQuery("UPDATE users SET ACL = 'SUPER' WHERE USERNAME = 'root'"); QSqlQuery("PRAGMA user_version = " + QString::number(DB_VERSION)); break; }