Updates
Update LearnHouse regularly to get the latest features, bug fixes, and security patches.
Updating LearnHouse
Use the built-in update command. It backs up your database, pulls the new image, migrates uploaded content to a persistent volume, restarts the stack, and applies database migrations.
# Update to the latest version
npx learnhouse update
# Update to a specific version
npx learnhouse update --to 1.4.2
# or using the short form:
npx learnhouse update -v 1.4.2| Flag | Description |
|---|---|
-v, --to <version> | Pull a specific image tag (e.g. 1.4.2, v1.4.2). Defaults to latest. |
--migrate | Run database migrations without prompting |
--no-migrate | Skip database migrations without prompting |
--no-backup | Skip the pre-upgrade database backup (not recommended for production) |
The update command creates a database backup automatically before making any changes. The backup is saved to {installDir}/backups/db-pre-upgrade-{timestamp}.sql.gz.
What update Does
The command runs these steps in order:
- Database backup:
pg_dumpto./backups/(skipped with--no-backup) - Alembic baseline: stamps the current schema for installs that pre-date Alembic tracking (one-time, idempotent)
- Image tag update: rewrites the tag in
docker-compose.yml - Content volume migration: moves uploaded media into a named Docker volume so it survives future container recreations (one-time, idempotent)
- Image pull:
docker compose pullfetches the new image - Stack restart:
docker compose down && docker compose up -d --pull always - Health wait: polls
/api/v1/healthuntil the app responds - Database migrations:
alembic upgrade head(prompted unless--migrate/--no-migratepassed)
Recommended Update Procedure
# 1. Review the release notes
# https://github.com/learnhouse/learnhouse/releases
# 2. Run the update (backup is created automatically)
npx learnhouse update
# 3. Verify all services are healthy
npx learnhouse doctor
# 4. Check logs for any errors
npx learnhouse logsDatabase Migrations
LearnHouse uses Alembic to evolve the database schema between versions. After the new container starts, the CLI prompts:
? Run database migrations now? › Yes / No- Yes: runs
alembic upgrade headin the app container. Recommended. - No: skips migrations. You can run them later manually.
To skip the prompt, pass --migrate (always run) or --no-migrate (always skip).
If you skip migrations, the new version of the app may error until they are applied. Run them manually when ready:
docker compose exec learnhouse-app sh -c "cd /app/api && uv run alembic upgrade head"Installs Created Before v1.3
Early LearnHouse installs created their schema via SQLAlchemy’s create_all without Alembic tracking. The update command detects this automatically and stamps the current schema as the baseline before running any delta migrations, so upgrade head applies only new changes instead of replaying everything.
Rolling Back
If an update causes issues, restore from the pre-upgrade backup:
# List available backups
ls {installDir}/backups/
# Restore the database
npx learnhouse restore backups/db-pre-upgrade-<timestamp>.sql.gz
# Revert the image tag in docker-compose.yml to the previous version
# (edit the file: change image: ghcr.io/learnhouse/app:<new> back to <old>)
# Restart on the old image
npx learnhouse startBackups are named db-pre-upgrade-{timestamp}.sql.gz when created by update, and learnhouse-backup-{timestamp}.tar.gz when created by the backup command. The pre-upgrade backup created by update includes only the database dump; to also preserve your .env, run npx learnhouse backup manually before updating.
Uploaded files stored on the filesystem (in the learnhouse_content_* Docker volume) are not included in the database backup. To back up uploaded files, use docker volume export or a volume-level snapshot provided by your hosting platform.
Checking for Updates
The CLI automatically checks for a new version each time you run a command and prints a notice if one is available.
Review the LearnHouse release notes before updating to understand what has changed. Some updates may include:
- New features or UI changes
- Database migrations (applied automatically when you accept the prompt or pass
--migrate) - Configuration changes that may require updating your
.envfile - Breaking changes (rare, documented in release notes with a migration guide)