aboutsummaryrefslogtreecommitdiff
path: root/lib/database.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2022-03-07 20:56:23 +0100
committerTobias Fella <fella@posteo.de>2022-03-07 20:56:23 +0100
commitce32dc09a9257ce5cb3188879f549d9b2fa816a1 (patch)
tree1ac84d8503e0b94ecd942c51bdcb26f4a5a91ecb /lib/database.cpp
parentfb9d7dc22c74022b914b1964965ed6b8b850d831 (diff)
downloadlibquotient-ce32dc09a9257ce5cb3188879f549d9b2fa816a1.tar.gz
libquotient-ce32dc09a9257ce5cb3188879f549d9b2fa816a1.zip
Add datbase migration
Diffstat (limited to 'lib/database.cpp')
-rw-r--r--lib/database.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/database.cpp b/lib/database.cpp
index 13b41a70..d070e1de 100644
--- a/lib/database.cpp
+++ b/lib/database.cpp
@@ -28,6 +28,7 @@ Database::Database(const QString& matrixId, const QString& deviceId, QObject* pa
switch(version()) {
case 0: migrateTo1();
+ case 1: migrateTo2();
}
}
@@ -83,7 +84,7 @@ void Database::migrateTo1()
transaction();
execute(QStringLiteral("CREATE TABLE accounts (pickle TEXT);"));
execute(QStringLiteral("CREATE TABLE olm_sessions (senderKey TEXT, sessionId TEXT, pickle TEXT);"));
- execute(QStringLiteral("CREATE TABLE inbound_megolm_sessions (roomId TEXT, senderKey TEXT, sessionId TEXT, ed25519Key TEXT, pickle TEXT);"));
+ execute(QStringLiteral("CREATE TABLE inbound_megolm_sessions (roomId TEXT, senderKey TEXT, sessionId TEXT, pickle TEXT);"));
execute(QStringLiteral("CREATE TABLE outbound_megolm_sessions (roomId TEXT, senderKey TEXT, sessionId TEXT, pickle TEXT);"));
execute(QStringLiteral("CREATE TABLE group_session_record_index (roomId TEXT, sessionId TEXT, i INTEGER, eventId TEXT, ts INTEGER);"));
execute(QStringLiteral("CREATE TABLE tracked_users (matrixId TEXT);"));
@@ -94,6 +95,15 @@ void Database::migrateTo1()
commit();
}
+void Database::migrateTo2()
+{
+ qCDebug(DATABASE) << "Migrating database to version 2";
+ transaction();
+ execute(QStringLiteral("ALTER TABLE inbound_megolm_sessions ADD ed25519Key TEXT"));
+ execute(QStringLiteral("PRAGMA user_version = 2;"));
+ commit();
+}
+
QByteArray Database::accountPickle()
{
auto query = prepareQuery(QStringLiteral("SELECT pickle FROM accounts;"));