Page MenuHomePhabricator

D11168.id37811.diff
No OneTemporary

D11168.id37811.diff

diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -512,6 +512,24 @@
return create_table(db, query, "communities");
}
+bool create_messages_to_device_table(sqlite3 *db) {
+ std::string query =
+ "CREATE TABLE IF NOT EXISTS messages_to_device ("
+ " message_id TEXT NOT NULL,"
+ " device_id TEXT NOT NULL,"
+ " user_id TEXT NOT NULL,"
+ " timestamp BIGINT NOT NULL,"
+ " plaintext TEXT NOT NULL,"
+ " ciphertext TEXT NOT NULL,"
+ " PRIMARY KEY (message_id, device_id)"
+ ");"
+
+ "CREATE INDEX IF NOT EXISTS messages_to_device_idx_id_timestamp"
+ " ON messages_to_device (device_id, timestamp);";
+
+ return create_table(db, query, "messages_to_device");
+}
+
bool create_schema(sqlite3 *db) {
char *error;
sqlite3_exec(
@@ -605,11 +623,25 @@
" community_info TEXT NOT NULL"
");"
+ "CREATE TABLE IF NOT EXISTS messages_to_device ("
+ " message_id TEXT NOT NULL,"
+ " device_id TEXT NOT NULL,"
+ " user_id TEXT NOT NULL,"
+ " timestamp BIGINT NOT NULL,"
+ " plaintext TEXT NOT NULL,"
+ " ciphertext TEXT NOT NULL,"
+ " PRIMARY KEY (message_id, device_id)"
+ ");"
+
"CREATE INDEX IF NOT EXISTS media_idx_container"
" ON media (container);"
"CREATE INDEX IF NOT EXISTS messages_idx_thread_time"
- " ON messages (thread, time);",
+ " ON messages (thread, time);"
+
+ "CREATE INDEX IF NOT EXISTS messages_to_device_idx_id_timestamp"
+ " ON messages_to_device (device_id, timestamp);",
+
nullptr,
nullptr,
&error);
@@ -845,7 +877,8 @@
{32, {create_users_table, true}},
{33, {create_keyservers_table, true}},
{34, {enable_rollback_journal_mode, false}},
- {35, {create_communities_table, true}}}};
+ {35, {create_communities_table, true}},
+ {36, {create_messages_to_device_table, true}}}};
enum class MigrationResult { SUCCESS, FAILURE, NOT_APPLIED };
@@ -1796,7 +1829,8 @@
std::string removeDeviceSpecificDataSQL =
"DELETE FROM olm_persist_account;"
"DELETE FROM olm_persist_sessions;"
- "DELETE FROM metadata;";
+ "DELETE FROM metadata;"
+ "DELETE FROM messages_to_device;";
executeQuery(backupDB, removeDeviceSpecificDataSQL);
executeQuery(backupDB, "VACUUM;");
sqlite3_close(backupDB);
diff --git a/web/database/_generated/comm_query_executor.wasm b/web/database/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 7:12 PM (8 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700868
Default Alt Text
D11168.id37811.diff (2 KB)

Event Timeline