update upgrade documentation and migration example for clarity

This commit is contained in:
GitHub
2025-12-30 12:16:46 +08:00
parent 1959a0e919
commit 94f5e17335
2 changed files with 10 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
> [!CAUTION]
> 1. You **cannot** upgrade directly from v0.7.x to v0.9.x. You must first upgrade to v0.8.x, then to v0.9.x.
> 2. Always back up your database before performing an upgrade.
> 2. Always back up your database before performing an upgrade and stop the running instance of Freedit.
> 3. Please view the upgrade examples in the [`examples/`](examples/) directory for more details.
> 4. You need to have Rust installed to run the upgrade scripts. Install Rust from [here](https://www.rust-lang.org/tools/install).
@@ -14,7 +14,9 @@ Change the underlying database from sled to fjall.
#### How?
`cargo run --example v0_8-v0_9`
1. `cargo run --example v0_8-v0_9 -- <path to v0.8 db>`
2. Set db path to the new db file in `config.toml` file.
3. Replace the old binary with the new binary.
### Upgrading from v0.7.x to v0.8.x
@@ -27,5 +29,8 @@ A lot of technical debt has been paid off in v0.8.x, including:
#### How?
`cargo run --example v0_7-v0_8 -- <path to v0.7 db>`
1. `cargo run --example v0_7-v0_8 -- <path to v0.7 db>`
2. Add `podcast_path = "data/podcasts"` and `snapshots_path = "data/snapshots"` in config.toml file.
3. Set db path to the new db file in `config.toml` file.
4. Replace the old binary with the new binary.

View File

@@ -6,15 +6,14 @@ use serde::Serialize;
use std::collections::HashMap;
fn main() {
let db_url = std::env::args()
.nth(1)
.unwrap_or_else(|| "freedit.db".to_owned());
let db_url = std::env::args().nth(1).unwrap();
// check if file exists
if !std::path::Path::new(&db_url).exists() {
panic!("Database file {} does not exist", db_url);
}
println!("Starting migration from v0.7 to v0.8...");
let config = sled::Config::default().path(db_url);
let db = config.open().unwrap();