agentmux_srv/migrations/
m0003_template_sessions_v1.rs1use std::sync::Arc;
5use crate::backend::storage::store::Store;
6use crate::backend::storage::filestore::FileStore;
7use super::{Migration, MigrationContext, MigrationError, MigrationScope};
8
9pub struct M0003TemplateSessionsV1;
10
11impl Migration for M0003TemplateSessionsV1 {
12 fn id(&self) -> &'static str { "0003_template_sessions_v1" }
13 fn scope(&self) -> MigrationScope { MigrationScope::Channel }
14 fn description(&self) -> &'static str { "Promote template sessions to user-owned definitions" }
15
16 fn up(&self, ctx: &MigrationContext) -> Result<(), MigrationError> {
17 if !ctx.channel_store_path.exists() {
18 return Ok(());
19 }
20 let mstore = Arc::new(
21 Store::open(&ctx.channel_store_path)
22 .map_err(|e| MigrationError(format!("template_sessions_v1: open mstore: {}", e)))?,
23 );
24 let filestore_path = ctx.data_dir.join("db").join("filestore.db");
25 let filestore = Arc::new(
26 FileStore::open(&filestore_path)
27 .map_err(|e| MigrationError(format!("template_sessions_v1: open filestore: {}", e)))?,
28 );
29 crate::backend::agent_session::migrate_promote_template_sessions_v1(&mstore, &filestore, &ctx.data_dir);
30 Ok(())
31 }
32
33 }