Migration
Upgrade Mnemosyne versions and migrate data between instances.
Version Upgrade
Check Current Version
python -c "import mnemosyne; print(mnemosyne.__version__)"
Upgrade Steps
# 1. Backup current database
cp mnemosyne.db mnemosyne-pre-upgrade.db
# 2. Upgrade package
pip install --upgrade mnemosyne-memory
# 3. Verify (schema migrations run automatically on first connection)
python -c "from mnemosyne import Memory; m = Memory(); print(m.stats())"
Automatic Migrations
Mnemosyne uses automatic schema migrations that run on first connection after an upgrade. There is no python -m mnemosyne.migrate command. If migration fails, check logs with MNEMOSYNE_LOG_LEVEL=debug.
Schema Migrations
Mnemosyne uses automatic schema migrations:
| Version | Migration | Description |
|---|---|---|
| 1.0 → 2.0 | m_1_0_to_2_0 | Add semantic memory, FTS5 indices |
| 2.0 → 2.1 | m_2_0_to_2_1 | Add session_id to episodic |
| 2.1 → 2.2 | m_2_1_to_2_2 | Add temporal graph indexes |
Migrations run automatically on first connection. No manual intervention needed.
Cross-Instance Migration
Export from old instance, import to new using the Python SDK:
from mnemosyne import Memory
# Export from old database
old_mem = Memory(db_path="old.db")
old_mem.export_to_file("export.json")
# Import into new database
new_mem = Memory(db_path="new.db")
new_mem.import_from_file("export.json")
# Verify
print(new_mem.stats())
Export Formats
| Format | Use Case | Size |
|---|---|---|
| JSON | Human-readable, version control | Large |
| SQLite | Fast, preserves all metadata | Compact |
Legacy Migration
For migrating from pre-2.0 data formats, use the migration script:
python scripts/migrate_from_legacy.py --db mnemosyne.db
Rollback
If upgrade fails:
# Stop application
# Restore pre-upgrade backup
cp mnemosyne-pre-upgrade.db mnemosyne.db
# Downgrade package
pip install mnemosyne-memory==1.0.0
# Restart
Breaking Changes
Major version upgrades (1.x → 2.x) may include breaking changes. Always read the changelog and test in staging before production deployment.
Related Pages
Backups
Implement backup strategies for Mnemosyne: SQLite file snapshots, incremental backups, automated res...
Installation Guide
Complete installation instructions for Mnemosyne including Python version requirements, optional dep...
Deployment Overview
Overview of Mnemosyne deployment options: Docker, Fly.io, systemd services, and cron jobs. Choose th...
Mnemosyne