Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- After the merge of https://github.com/matrix-org/matrix-rust-sdk/pull/5648,
-- we want all events to get a `TimelineEvent::timestamp` value (extracted from
-- `origin_server_ts`).
--
-- To accomplish that, we are emptying the event cache. New synced events will
-- be built correctly, with a valid `TimelineEvent::timestamp`, allowing a
-- clear, stable situation.

DELETE from linked_chunks;
DELETE from event_chunks; -- should be done by cascading
DELETE from gap_chunks; -- should be done by cascading
DELETE from events;
12 changes: 11 additions & 1 deletion crates/matrix-sdk-sqlite/src/event_cache_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const DATABASE_NAME: &str = "matrix-sdk-event-cache.sqlite3";
/// This is used to figure whether the SQLite database requires a migration.
/// Every new SQL migration should imply a bump of this number, and changes in
/// the [`run_migrations`] function.
const DATABASE_VERSION: u8 = 10;
const DATABASE_VERSION: u8 = 11;

/// The string used to identify a chunk of type events, in the `type` field in
/// the database.
Expand Down Expand Up @@ -453,6 +453,16 @@ async fn run_migrations(conn: &SqliteAsyncConn, version: u8) -> Result<()> {
}
}

if version < 11 {
conn.with_transaction(|txn| {
txn.execute_batch(include_str!(
"../migrations/event_cache_store/011_empty_event_cache.sql"
))?;
txn.set_db_version(11)
})
.await?;
}

Ok(())
}

Expand Down
Loading