Skip to content

Latest commit

 

History

History
157 lines (108 loc) · 3.34 KB

File metadata and controls

157 lines (108 loc) · 3.34 KB
title Upgrade Second Brain
type how-to

Upgrade Second Brain

Safely upgrade a running instance to the latest version: pull code, apply migrations, update dependencies, and restart services.

Prerequisites

Note

Before you begin, ensure you have:

  • A working Second Brain installation (see Getting started)
  • PostgreSQL 17 running (pg_isready -h 127.0.0.1 -p 5432 -U memory_bank)
  • The .venv activated (source .venv/bin/activate)

1. Review recent changes

Skim the commit log or changelog for breaking changes before upgrading:

git log --oneline HEAD..origin/main | head -20

Look for migration files, dependency changes, or notes about config format updates.

Tip

Nightly backups run at 2:00 AM (Google Drive + local, encrypted). A manual pre-upgrade backup is optional — your data is already protected. If you want one anyway: bash scripts/jobs/backup.sh

2. Pull the latest code

git pull origin main

Expected output:

Updating a1b2c3d..e4f5g6h
Fast-forward
 src/mcp_server.py | 12 ++++++------
 migrations/011_new_index.sql | 8 ++++++++
 ...

3. Apply new migrations

The migration runner is idempotent — it skips already-applied versions and is safe to re-run:

./migrations/migrate.sh

Expected output:

skip: 001_initial_schema.sql (already applied)
skip: 002_v2_columns.sql (already applied)
...
apply: 011_new_index.sql
done

If all migrations were already applied, you see only skip: lines followed by done.

4. Reinstall dependencies (if changed)

Check whether requirements.txt changed in the pull:

git diff HEAD~1 -- requirements.txt

If it shows changes, reinstall:

pip install -r requirements.txt

Expected output (last line):

Successfully installed <new-or-updated-packages>

5. Restart services (if needed)

Restart PostgreSQL only if the upgrade notes mention a schema change that requires it, or if you experience connection issues:

brew services restart postgresql@17

Expected output:

Stopping `postgresql@17`... (was running)
==> Successfully started `postgresql@17`

If any launchd agents were updated (new or modified plists in scheduling/), reload them:

launchctl unload ~/Library/LaunchAgents/com.second-brain.<name>.plist
launchctl load ~/Library/LaunchAgents/com.second-brain.<name>.plist

Verify all jobs are loaded:

launchctl list | grep second-brain

Expected output:

-    0    com.second-brain.backup
-    0    com.second-brain.dream-cycle
...

6. Verify

Check PostgreSQL

pg_isready -h 127.0.0.1 -p 5432 -U memory_bank

Expected output:

127.0.0.1:5432 - accepting connections

Run the smoke test

.venv/bin/python -m pytest tests/test_db.py tests/test_search.py tests/test_mcp_server.py -q

Expected output:

... passed

Tests run against an isolated memory_bank_test database and mock Ollama calls — the local model does not need to run during tests.

Related