Skip to content

Upgrading

Upgrading TheTerms is straightforward. The container startup script automatically applies database migrations.

  1. Back up your database before upgrading (recommended)

    Terminal window
    docker compose exec postgres pg_dump -U postgres theterms > backup-pre-upgrade.sql
  2. Pull the latest code

    Terminal window
    git pull
  3. Rebuild and restart all services

    Terminal window
    docker compose up -d --build

    The new container will:

    • Build the updated Next.js application
    • Apply any new database migrations via prisma migrate deploy
    • Start serving traffic

The current Docker Compose setup has a brief downtime window during rebuild. For zero-downtime deployments, consider:

  • Using a load balancer with multiple app containers
  • Blue-green deployment (run a second stack, shift traffic, stop the first)

If something goes wrong after an upgrade:

Terminal window
# Check out a previous version
git log --oneline -10 # find the previous commit
git checkout <previous-commit>
# Rebuild from that version
docker compose up -d --build

For database rollbacks, restore from your pre-upgrade backup:

Terminal window
docker compose stop app
docker compose exec -T postgres psql -U postgres theterms < backup-pre-upgrade.sql
docker compose up -d