agent: lumotia-rebrand — data dir migration shim + paths.rs rename
Phase 5 of the rebrand cascade per locked decision D1 (migrate in place).
crates/core/src/paths.rs:
- Hardcoded subdir strings renamed: magnotia/Magnotia -> lumotia/Lumotia
across all four OS branches (Linux XDG + dot-legacy, macOS Application
Support, Windows LOCALAPPDATA, fallback dot-dir).
- Database filename: magnotia.db -> lumotia.db.
- Test path fixtures renamed: /tmp/magnotia-test -> /tmp/lumotia-test.
- New MigrationStatus enum (Migrated / TargetAlreadyExists / NoLegacyFound).
- New migrate_legacy_data_dir() that probes the platform-correct legacy
magnotia path, renames it to the lumotia equivalent via fs::rename, and
also renames magnotia.db -> lumotia.db inside if found. Idempotent: safe
to call on every boot. Refuses to overwrite an existing lumotia dir to
protect user data.
- Four new unit tests covering all branches via the test-friendly
migrate_legacy_data_dir_inner that takes an explicit legacy path.
crates/storage/src/database.rs:
- New migrate_legacy_setting_keys(pool) that renames any settings rows
with key matching magnotia_* to lumotia_*. Single SQL UPDATE with
NOT EXISTS guard so it leaves rows alone if a lumotia_ row already
exists. Re-exported from lib.rs.
src-tauri/src/lib.rs:
- Calls migrate_legacy_data_dir(&app_data_dir()) at the start of setup()
BEFORE database_path() resolves the now-renamed dir. Logs migration
outcome to lumotia_startup tracing target.
- Calls migrate_legacy_setting_keys(&db) immediately after init_db
returns. Logs only when rows are actually renamed.
src-tauri/src/{lib,commands/{diagnostics,rituals,transcripts}}.rs +
crates/storage/src/database.rs:
- All in-code references to magnotia_preferences, magnotia_history (in
comments), and magnotia_morning_triage_last_shown renamed to lumotia_*.
cargo build --workspace passes. cargo test --workspace: 334 pass, 0 fail
(up from 330; +4 paths::tests).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -905,6 +905,31 @@ pub async fn get_setting(pool: &SqlitePool, key: &str) -> Result<Option<String>>
|
||||
Ok(row.map(|r| r.get("value")))
|
||||
}
|
||||
|
||||
/// One-shot key rename for settings rows carried over from the magnotia era
|
||||
/// (`magnotia_preferences`, `magnotia_morning_triage_last_shown`, etc.).
|
||||
///
|
||||
/// Idempotent: rows already on the new key are left alone; rows on the old
|
||||
/// key are renamed only if the new key does not already exist. Returns the
|
||||
/// number of rows actually renamed so the caller can log on first launch.
|
||||
pub async fn migrate_legacy_setting_keys(pool: &SqlitePool) -> Result<u64> {
|
||||
let result = sqlx::query(
|
||||
"UPDATE settings \
|
||||
SET key = 'lumotia_' || substr(key, length('magnotia_') + 1) \
|
||||
WHERE key LIKE 'magnotia_%' \
|
||||
AND NOT EXISTS (\
|
||||
SELECT 1 FROM settings AS dst \
|
||||
WHERE dst.key = 'lumotia_' || substr(settings.key, length('magnotia_') + 1)\
|
||||
)",
|
||||
)
|
||||
.execute(pool)
|
||||
.await
|
||||
.map_err(|source| Error::Query {
|
||||
operation: "migrate_legacy_setting_keys".into(),
|
||||
source,
|
||||
})?;
|
||||
Ok(result.rows_affected())
|
||||
}
|
||||
|
||||
// --- Row types ---
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -944,7 +969,7 @@ pub struct TranscriptRow {
|
||||
pub anti_hallucination: bool,
|
||||
pub created_at: String,
|
||||
// Task 2.5 — transcripts_meta (migration v5). Persists the UI metadata
|
||||
// that previously lived in the removed localStorage `magnotia_history` cache.
|
||||
// that previously lived in the removed localStorage `lumotia_history` cache.
|
||||
pub starred: bool,
|
||||
pub manual_tags: String,
|
||||
pub template: String,
|
||||
|
||||
Reference in New Issue
Block a user