Skip to content

Commit

Permalink
migrate to storage schema 8
Browse files Browse the repository at this point in the history
  • Loading branch information
unclekingpin committed Oct 20, 2023
1 parent d12b689 commit c01ee05
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/runtime/env.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::addon_transport::{AddonHTTPTransport, AddonTransport, UnsupportedTransport};
use crate::constants::{
LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY, PROFILE_STORAGE_KEY, SCHEMA_VERSION,
SCHEMA_VERSION_STORAGE_KEY,
SCHEMA_VERSION_STORAGE_KEY, STREAMS_STORAGE_KEY,
};
use crate::models::ctx::Ctx;
use crate::models::streaming_server::StreamingServer;
Expand Down Expand Up @@ -220,6 +220,12 @@ pub trait Env {
.await?;
schema_version = 7;
};
if schema_version == 7 {
migrate_storage_schema_to_v8::<Self>()
.map_err(|error| EnvError::StorageSchemaVersionUpgrade(Box::new(error)))
.await?;
schema_version = 8;
}
if schema_version != SCHEMA_VERSION {
panic!(
"Storage schema version must be upgraded from {} to {}",
Expand Down Expand Up @@ -444,6 +450,12 @@ fn migrate_storage_schema_to_v7<E: Env>() -> TryEnvFuture<()> {
.boxed_env()
}

fn migrate_storage_schema_to_v8<E: Env>() -> TryEnvFuture<()> {
E::set_storage::<()>(STREAMS_STORAGE_KEY, None)
.and_then(|_| E::set_storage(SCHEMA_VERSION_STORAGE_KEY, Some(&8)))
.boxed_env()
}

#[cfg(test)]
mod test {
use serde_json::{json, Value};
Expand Down

0 comments on commit c01ee05

Please sign in to comment.