From ba1c13468942dce17d78e394ffabe2796cfed577 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 1 Nov 2024 22:16:14 +0000 Subject: [PATCH] move migrations out of globals service Signed-off-by: Jason Volk --- src/service/globals/mod.rs | 1 - src/service/media/migrations.rs | 4 ++-- src/service/{globals => }/migrations.rs | 0 src/service/mod.rs | 1 + src/service/services.rs | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename src/service/{globals => }/migrations.rs (100%) diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index 0a7dda9f..bd956964 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -1,5 +1,4 @@ mod data; -pub(super) mod migrations; use std::{ collections::HashMap, diff --git a/src/service/media/migrations.rs b/src/service/media/migrations.rs index 0e358d44..f1c6da7d 100644 --- a/src/service/media/migrations.rs +++ b/src/service/media/migrations.rs @@ -13,7 +13,7 @@ use conduit::{ warn, Config, Result, }; -use crate::{globals, Services}; +use crate::{migrations, Services}; /// Migrates a media directory from legacy base64 file names to sha2 file names. /// All errors are fatal. Upon success the database is keyed to not perform this @@ -50,7 +50,7 @@ pub(crate) async fn migrate_sha256_media(services: &Services) -> Result<()> { // Apply fix from when sha256_media was backward-incompat and bumped the schema // version from 13 to 14. For users satisfying these conditions we can go back. - if services.globals.db.database_version().await == 14 && globals::migrations::DATABASE_VERSION == 13 { + if services.globals.db.database_version().await == 14 && migrations::DATABASE_VERSION == 13 { services.globals.db.bump_database_version(13)?; } diff --git a/src/service/globals/migrations.rs b/src/service/migrations.rs similarity index 100% rename from src/service/globals/migrations.rs rename to src/service/migrations.rs diff --git a/src/service/mod.rs b/src/service/mod.rs index 604e3404..c7dcc0c6 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -1,6 +1,7 @@ #![allow(refining_impl_trait)] mod manager; +mod migrations; mod service; pub mod services; diff --git a/src/service/services.rs b/src/service/services.rs index c0af4249..b86e7a72 100644 --- a/src/service/services.rs +++ b/src/service/services.rs @@ -114,7 +114,7 @@ impl Services { debug_info!("Starting services..."); self.admin.set_services(Some(Arc::clone(self)).as_ref()); - globals::migrations::migrations(self).await?; + super::migrations::migrations(self).await?; self.manager .lock() .await