aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/database.cpp12
-rw-r--r--lib/database.h1
2 files changed, 12 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;"));
diff --git a/lib/database.h b/lib/database.h
index f6a491fb..f9a8df1a 100644
--- a/lib/database.h
+++ b/lib/database.h
@@ -37,6 +37,7 @@ public:
private:
void migrateTo1();
+ void migrateTo2();
QString m_matrixId;
};
}