matrix_sdk_indexeddb/crypto_store/migrations/v11_to_v12.rs
1// Copyright 2024 The Matrix.org Foundation C.I.C.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use indexed_db_futures::{error::OpenDbError, Build};
16
17use crate::crypto_store::{keys, migrations::do_schema_upgrade, Result};
18
19/// Perform the schema upgrade v11 to v12, adding an index on
20/// `(curve_key, sender_data_type, session_id)` to `inbound_group_sessions3`.
21pub(crate) async fn schema_add(name: &str) -> Result<(), OpenDbError> {
22 do_schema_upgrade(name, 12, |transaction, _| {
23 let object_store = transaction.object_store(keys::INBOUND_GROUP_SESSIONS_V3)?;
24
25 object_store
26 .create_index(
27 keys::INBOUND_GROUP_SESSIONS_SENDER_KEY_INDEX,
28 ["sender_key", "sender_data_type", "session_id"].into(),
29 )
30 .build()?;
31
32 Ok(())
33 })
34 .await
35}