diff options
author | Tobias Fella <fella@posteo.de> | 2022-03-07 20:56:23 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2022-03-07 20:56:23 +0100 |
commit | ce32dc09a9257ce5cb3188879f549d9b2fa816a1 (patch) | |
tree | 1ac84d8503e0b94ecd942c51bdcb26f4a5a91ecb | |
parent | fb9d7dc22c74022b914b1964965ed6b8b850d831 (diff) | |
download | libquotient-ce32dc09a9257ce5cb3188879f549d9b2fa816a1.tar.gz libquotient-ce32dc09a9257ce5cb3188879f549d9b2fa816a1.zip |
Add datbase migration
-rw-r--r-- | lib/database.cpp | 12 | ||||
-rw-r--r-- | lib/database.h | 1 |
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; }; } |