From 8e966c7ac4582de3ed84c735e3218f1733d0b986 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Tue, 17 Sep 2024 22:20:59 -0700 Subject: [PATCH] error migrating to/from conduit with conduit_compat disabled In the future, we'll probably want to implement real support for changing the admin bot userid. For now, just error so things don't break in confusing ways. We should note in the docs when creating a new server, that if you don't enable conduit_compat you won't currently be able to migrate away. --- src/cli/migrate_db.rs | 9 +++++++++ src/error.rs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/cli/migrate_db.rs b/src/cli/migrate_db.rs index 1d06b9a2..c80fc79b 100644 --- a/src/cli/migrate_db.rs +++ b/src/cli/migrate_db.rs @@ -79,6 +79,15 @@ pub(crate) async fn run( info!("Migrating from {current:?} to {target:?}"); + if !services().globals.config.conduit_compat { + if let DbMigrationTarget::Conduit(_) = args.to { + return Err(Error::ConduitCompatDisabled); + } + if let DbVersion::Conduit(_) = current { + return Err(Error::ConduitCompatDisabled); + } + } + if target == current { // No-op } else if target == latest { diff --git a/src/error.rs b/src/error.rs index 727a6cb6..33bd121b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -97,6 +97,14 @@ pub(crate) enum MigrateDbCommand { #[error("output path is not valid unicode")] InvalidUnicodeOutPath, + #[error( + "conduit_compat config option must be enabled to migrate database to \ + or from conduit. Note that you cannot currently enable \ + conduit_compat on a database that was originally created in \ + grapevine with it disabled." + )] + ConduitCompatDisabled, + #[error( "migrating a database may lose data even if the migration is \ successful. Because of this, it is very important to ensure you have \