Skip to content

Commit a9e6fc6

Browse files
committed
fix: Update AvatarRecord index with new columns
1 parent 2a91482 commit a9e6fc6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

crates/prose-core-client/src/infra/platform_dependencies.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(crate) struct PlatformDependencies {
7575
pub xmpp: Arc<XMPPClient>,
7676
}
7777

78-
const DB_VERSION: u32 = 32;
78+
const DB_VERSION: u32 = 33;
7979

8080
pub async fn open_store<D: Driver>(driver: D) -> Result<Store<D>, D::Error> {
8181
let versions_changed = Arc::new(AtomicBool::new(false));
@@ -207,7 +207,7 @@ pub async fn open_store<D: Driver>(driver: D) -> Result<Store<D>, D::Error> {
207207
create_collection::<D, MessageRecord>(&tx)?;
208208
}
209209

210-
if event.old_version < 31 {
210+
if event.old_version < 32 {
211211
#[cfg(target_arch = "wasm32")]
212212
{
213213
tx.delete_collection(crate::infra::user_info::AvatarRecord::collection())?;
@@ -217,6 +217,14 @@ pub async fn open_store<D: Driver>(driver: D) -> Result<Store<D>, D::Error> {
217217
create_collection::<D, WorkspaceInfoRecord>(&tx)?;
218218
}
219219

220+
if event.old_version < 33 {
221+
#[cfg(target_arch = "wasm32")]
222+
{
223+
tx.delete_collection(crate::infra::user_info::AvatarRecord::collection())?;
224+
create_collection::<D, crate::infra::user_info::AvatarRecord>(&tx)?;
225+
}
226+
}
227+
220228
Ok(())
221229
})
222230
.await?;

crates/prose-core-client/src/infra/user_info/store_avatar_repository.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ impl AvatarRecord {
5555

5656
mod columns {
5757
pub const ACCOUNT: &str = "account";
58-
pub const PARTICIPANT_ID: &str = "participant_id";
58+
pub const ENTITY_ID: &str = "entity_id";
5959
pub const AVATAR_ID: &str = "avatar_id";
6060
}
6161

6262
define_entity!(AvatarRecord, "avatar",
6363
account_idx => { columns: [columns::ACCOUNT], unique: false },
6464
// We're only saving one avatar per user
65-
user_idx => { columns: [columns::ACCOUNT, columns::PARTICIPANT_ID], unique: true },
66-
avatar_idx => { columns: [columns::ACCOUNT, columns::PARTICIPANT_ID, columns::AVATAR_ID], unique: true }
65+
user_idx => { columns: [columns::ACCOUNT, columns::ENTITY_ID], unique: true },
66+
avatar_idx => { columns: [columns::ACCOUNT, columns::ENTITY_ID, columns::AVATAR_ID], unique: true }
6767
);
6868

6969
impl KeyType for AvatarId {

0 commit comments

Comments
 (0)