From 620ef3104f0a41c9a333a727d41075306cd32773 Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Sun, 2 Nov 2025 12:51:43 -0700 Subject: [PATCH] chore(engine): add `db nuke` subcommand --- engine/packages/engine/src/commands/db/mod.rs | 21 +++++++++++++++++++ scripts/run/engine-rocksdb.sh | 2 +- scripts/run/nuke-rocksdb.sh | 9 ++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 scripts/run/nuke-rocksdb.sh diff --git a/engine/packages/engine/src/commands/db/mod.rs b/engine/packages/engine/src/commands/db/mod.rs index a447097e7a..d3caff16aa 100644 --- a/engine/packages/engine/src/commands/db/mod.rs +++ b/engine/packages/engine/src/commands/db/mod.rs @@ -12,6 +12,10 @@ pub enum SubCommand { #[clap(short = 'q', long)] query: Option, }, + Nuke { + #[clap(long)] + yes: bool, + }, } #[derive(ValueEnum, Clone, PartialEq)] @@ -54,6 +58,23 @@ impl SubCommand { Ok(()) } + Self::Nuke { yes } => { + if !yes { + bail!("Please pass '--yes' flag to confirm you want to nuke the database"); + } + + match config.database() { + rivet_config::config::Database::Postgres(_) => { + bail!("nuke postgres not implemented"); + } + rivet_config::config::Database::FileSystem(file_system) => { + println!("Removing {}", file_system.path.display()); + tokio::fs::remove_dir_all(&file_system.path).await?; + println!("Complete"); + Ok(()) + } + } + } } } } diff --git a/scripts/run/engine-rocksdb.sh b/scripts/run/engine-rocksdb.sh index 572101f0b8..c2897ff140 100755 --- a/scripts/run/engine-rocksdb.sh +++ b/scripts/run/engine-rocksdb.sh @@ -6,5 +6,5 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" cd "${REPO_ROOT}" -RUST_LOG=debug \ +RUST_LOG="${RUST_LOG:-debug}" \ cargo run --bin rivet-engine -- start "$@" diff --git a/scripts/run/nuke-rocksdb.sh b/scripts/run/nuke-rocksdb.sh new file mode 100755 index 0000000000..3423a19ab3 --- /dev/null +++ b/scripts/run/nuke-rocksdb.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" + +cd "${REPO_ROOT}" + +rm -rf "~/Library/Application Support/rivet-engine/"