Skip to main content

tuwunel_service/migrations/
split_conduit_highlight_counts.rs

1use tuwunel_core::{Result, result::NotFound};
2
3use super::conduit::migrate_conduit_highlight_split;
4use crate::Services;
5
6/// Splits a Conduit database's conflated highlight-count column once.
7///
8/// Conduit aliased `roomuserid_lastnotificationread` onto the
9/// `userroomid_highlightcount` tree, so one column holds both stores; tuwunel
10/// keeps them apart. Gated on its own marker; the split itself returns early
11/// unless a room-keyed row is present, so it is a cheap no-op on a native
12/// database.
13pub(super) async fn split_conduit_highlight_counts(services: &Services) -> Result {
14	let db = &services.db;
15
16	if db["global"]
17		.get(b"split_conduit_highlight")
18		.await
19		.is_not_found()
20	{
21		migrate_conduit_highlight_split(services).await?;
22		db["global"].insert(b"split_conduit_highlight", []);
23	}
24
25	Ok(())
26}