Skip to content

Commit cf3b3e3

Browse files
committed
chore(engine): add db nuke subcommand
1 parent 9d52114 commit cf3b3e3

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

engine/packages/engine/src/commands/db/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ pub enum SubCommand {
1212
#[clap(short = 'q', long)]
1313
query: Option<String>,
1414
},
15+
Nuke {
16+
#[clap(long)]
17+
yes: bool,
18+
},
1519
}
1620

1721
#[derive(ValueEnum, Clone, PartialEq)]
@@ -54,6 +58,23 @@ impl SubCommand {
5458

5559
Ok(())
5660
}
61+
Self::Nuke { yes } => {
62+
if !yes {
63+
bail!("Please pass '--yes' flag to confirm you want to nuke the database");
64+
}
65+
66+
match config.database() {
67+
rivet_config::config::Database::Postgres(_) => {
68+
bail!("nuke postgres not implemented");
69+
}
70+
rivet_config::config::Database::FileSystem(file_system) => {
71+
println!("Removing {}", file_system.path.display());
72+
tokio::fs::remove_dir_all(&file_system.path).await?;
73+
println!("Complete");
74+
Ok(())
75+
}
76+
}
77+
}
5778
}
5879
}
5980
}

scripts/run/engine-rocksdb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
66

77
cd "${REPO_ROOT}"
88

9-
RUST_LOG=debug \
9+
RUST_LOG="${RUST_LOG:-debug}" \
1010
cargo run --bin rivet-engine -- start "$@"

scripts/run/nuke-rocksdb.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
6+
7+
cd "${REPO_ROOT}"
8+
9+
rm -rf "~/Library/Application Support/rivet-engine/"

0 commit comments

Comments
 (0)