Skip to main content

agentmux_srv/migrations/
m0006_definitions_global.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::registry;
5use super::{Migration, MigrationContext, MigrationError, MigrationScope};
6
7pub struct M0006DefinitionsGlobal;
8
9impl Migration for M0006DefinitionsGlobal {
10    fn id(&self) -> &'static str { "0006_definitions_global" }
11    fn scope(&self) -> MigrationScope { MigrationScope::Global }
12    fn description(&self) -> &'static str { "Migrate agent definitions from per-channel to global shared store" }
13
14    fn up(&self, ctx: &MigrationContext) -> Result<(), MigrationError> {
15        let def_dir = ctx.home.join("shared").join("agents").join("definitions");
16        let def_store = registry::DefinitionStore::open(def_dir)
17            .map_err(|e| MigrationError(format!("definitions_global: open def store: {}", e)))?;
18        registry::migrate_definitions_global_once(&ctx.home, &def_store)
19            .map(|_| ())
20            .map_err(|e| MigrationError(format!("definitions_global: {}", e)))
21    }
22}