Skip to content

Commit

Permalink
allow conduit database version 16
Browse files Browse the repository at this point in the history
Conduit bumped the database version to 16, but did not introduce any
breaking changes. Their database migrations are extremely fragile and risky,
and also do not really apply to us, so just to retain Conduit -> conduwuit
compatibility we'll check for both versions.

Signed-off-by: strawberry <[email protected]>
  • Loading branch information
girlbossceo committed Oct 25, 2024
1 parent f691883 commit 7e82844
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/service/globals/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ use crate::{media, Services};
/// equal or lesser version. These are expected to be backward-compatible.
pub(crate) const DATABASE_VERSION: u64 = 13;

/// Conduit's database version.
///
/// Conduit bumped the database version to 16, but did not introduce any
/// breaking changes. Their database migrations are extremely fragile and risky,
/// and also do not really apply to us, so just to retain Conduit -> conduwuit
/// compatibility we'll check for both versions.
pub(crate) const CONDUIT_DATABASE_VERSION: u64 = 16;

pub(crate) async fn migrations(services: &Services) -> Result<()> {
// Matrix resource ownership is based on the server name; changing it
// requires recreating the database from scratch.
Expand Down Expand Up @@ -148,9 +156,11 @@ async fn migrate(services: &Services) -> Result<()> {
retroactively_fix_bad_data_from_roomuserid_joined(services).await?;
}

assert_eq!(
services.globals.db.database_version().unwrap(),
DATABASE_VERSION,
let version_match = services.globals.db.database_version().unwrap() == DATABASE_VERSION
|| services.globals.db.database_version().unwrap() == CONDUIT_DATABASE_VERSION;

assert!(
version_match,
"Failed asserting local database version {} is equal to known latest conduwuit database version {}",
services.globals.db.database_version().unwrap(),
DATABASE_VERSION,
Expand Down

0 comments on commit 7e82844

Please sign in to comment.