Skip to content

Commit 52422ff

Browse files
committed
fix(sqlite): Make it possible to store the new SendRequestKey format.
1 parent e1980c9 commit 52422ff

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Delete all previous entries in the dependent send queue table, because the
2+
-- format of `parent_key` has changed.
3+
DELETE FROM "dependent_send_queue_events";
4+
5+
--- Delete all previous entries in the send queue too.
6+
DELETE FROM "send_queue_events";

crates/matrix-sdk-sqlite/src/state_store.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,17 @@ impl SqliteStateStore {
403403
.await?;
404404
}
405405

406+
if from < 15 && to >= 15 {
407+
conn.with_transaction(move |txn| {
408+
// Run the migration.
409+
txn.execute_batch(include_str!(
410+
"../migrations/state_store/013_send_queue_new_parent_key_format.sql"
411+
))?;
412+
txn.set_db_version(15)
413+
})
414+
.await?;
415+
}
416+
406417
Ok(())
407418
}
408419

@@ -2093,7 +2104,7 @@ impl StateStore for SqliteStateStore {
20932104
parent_key: SentRequestKey,
20942105
) -> Result<usize> {
20952106
let room_id = self.encode_key(keys::DEPENDENTS_SEND_QUEUE, room_id);
2096-
let parent_key = self.serialize_value(&parent_key)?;
2107+
let parent_key = self.serialize_json(&parent_key)?;
20972108

20982109
// See comment in `save_send_queue_request`.
20992110
let parent_txn_id = parent_txn_id.to_string();
@@ -2164,7 +2175,7 @@ impl StateStore for SqliteStateStore {
21642175
dependent_events.push(DependentQueuedRequest {
21652176
own_transaction_id: entry.0.into(),
21662177
parent_transaction_id: entry.1.into(),
2167-
parent_key: entry.2.map(|bytes| self.deserialize_value(&bytes)).transpose()?,
2178+
parent_key: entry.2.map(|json| self.deserialize_json(&json)).transpose()?,
21682179
kind: self.deserialize_json(&entry.3)?,
21692180
created_at,
21702181
});

0 commit comments

Comments
 (0)