Upgrading
This guide covers how to upgrade RAT to a new version, what to expect during the upgrade process, and how to roll back if something goes wrong.
Version Scheme
RAT follows Semantic Versioning (SemVer):
v2.MAJOR.MINOR| Component | When Incremented | Example |
|---|---|---|
| MAJOR | Breaking changes (schema migrations, API changes) | v2.1.0 → v2.2.0 |
| MINOR | New features, non-breaking improvements | v2.1.0 → v2.1.1 |
Releases are tagged in Git with the version number (e.g., v2.1.0).
The v2 prefix indicates this is the v2 rewrite of RAT. The major version within v2 tracks breaking changes within this generation.
Upgrade Process
Read the release notes
Before upgrading, read the release notes for every version between your current version and the target version. Pay attention to:
- Breaking changes that require manual action
- Database migrations that will run automatically
- Configuration changes (new/renamed environment variables)
- Deprecated features that will be removed in a future version
# Check your current version
curl -s http://localhost:8080/health | jq .version
# View release notes on GitHub
gh release list --repo squat-collective/rat
gh release view v2.2.0 --repo squat-collective/ratCreate a backup
Always backup before upgrading. See the Backup & Restore page for details.
# Dump Postgres
docker compose exec postgres pg_dump -U rat rat > backup-$(date +%Y%m%d).sqlPull new images
docker compose pullIf you pinned a version, update the image tags in docker-compose.yml first, or re-run the installer:
curl -fsSL https://raw.githubusercontent.com/squat-collective/rat/main/install/install.sh | bash -s -- --version=2.2.0 --dir=.Restart services
docker compose up -dDocker will recreate only the containers whose images have changed.
Verify the upgrade
# Check health
curl -s http://localhost:8080/health | jq .
# Check version
curl -s http://localhost:8080/health | jq .versionOpen the portal at localhost:3000 and verify that pipelines, runs, and queries work correctly.
Database Migrations
RAT runs database migrations automatically on startup. When ratd starts, it:
- Connects to PostgreSQL
- Checks the current schema version in the
schema_migrationstable - Applies any pending migrations in order
- Continues with normal startup
Migrations are idempotent — running them multiple times has no effect. If ratd restarts during a migration, it will resume from where it left off on the next startup.
Migration Behavior
| Scenario | Behavior |
|---|---|
| Fresh install | All migrations run from scratch, creating all tables |
| Upgrade by 1 version | Only the new version’s migration runs |
| Upgrade by multiple versions | All intermediate migrations run in sequence |
| Downgrade (not supported) | Migrations are forward-only. Use backup/restore for rollback |
Checking Migration Status
The schema_migrations table tracks which migrations have been applied:
docker compose -f infra/docker-compose.yml exec postgres \
psql -U rat -d rat -c "SELECT * FROM schema_migrations ORDER BY version;"Breaking Changes Policy
RAT follows these rules for breaking changes:
- Deprecation first: Features are deprecated for at least one minor version before removal
- Migration provided: Database schema changes include automatic migrations
- Configuration changes documented: New, renamed, or removed environment variables are listed in release notes
- API versioning: Breaking API changes increment the API version (
/api/v1→/api/v2). Old versions are supported for at least one major release - Proto compatibility: Protobuf changes are checked with
buf breakingin CI. Backward-incompatible changes require a new proto version
Types of Breaking Changes
| Change | Impact | Mitigation |
|---|---|---|
| Database schema change | Automatic migration on startup | No action needed |
| Renamed environment variable | Service fails to start with old config | Update your .env or compose file |
| Removed API endpoint | Client requests fail with 404 | Update client code to use new endpoint |
| Changed API response format | Client parsing breaks | Update client code |
| Proto message change | gRPC calls fail | Rebuild all services together |
| Behavioral change | Pipelines may produce different results | Test in staging first |
Rollback Procedure
If an upgrade causes problems, you can roll back to the previous version.
Stop all services
make downCheckout the previous version
git checkout v2.1.0 # your previous working versionRestore from backup
Because database migrations are forward-only, you must restore the database from the backup you created before upgrading:
make restore BACKUP_DIR=./backups/<pre-upgrade-timestamp>Rebuild images
make buildStart services
make upVerify rollback
curl -s http://localhost:8080/health | jq .
make smoke-testRolling back after a database migration means restoring from backup. Any data created between the upgrade and the rollback (new pipeline runs, uploaded files, etc.) will be lost. This is why creating a backup before upgrading is critical.
Zero-Downtime Upgrades
For environments that cannot tolerate downtime, consider this approach:
Rolling Update (Multiple Replicas)
If you run multiple ratd replicas behind a load balancer:
- Build new images
- Restart one replica at a time
- Wait for the new replica to become healthy before restarting the next
- The load balancer routes traffic to healthy replicas during the update
The runner and ratq services are stateless (from the platform’s perspective) and can be updated with zero downtime by running multiple replicas. The scheduler uses Postgres advisory locks for leader election, so only one replica runs the scheduler at a time.
Blue-Green Deployment
- Stand up a complete second stack (blue) with the new version
- Restore data from a backup to the blue stack
- Switch the load balancer from green (old) to blue (new)
- If problems occur, switch back to green
This approach requires double the infrastructure but provides the safest upgrade path.
Upgrade Checklist
- Read release notes for all versions between current and target
- Create backup (
make backup) - Verify backup integrity (spot-check files, dump size)
- Pull latest code and checkout target version
- Rebuild images (
make build) - Restart services (
make restart) - Check health (
curl http://localhost:8080/health) - Run smoke test (
make smoke-test) - Verify pipelines in the portal
- Monitor logs for errors for 30 minutes
- Remove old backup after confirming stability (optional)
Version Compatibility Matrix
When upgrading, all RAT services must run the same version. Do not mix versions across services.
| Component | Must Match | Notes |
|---|---|---|
| ratd | All services | Central coordinator |
| runner | ratd | gRPC protocol compatibility |
| ratq | ratd | gRPC protocol compatibility |
| portal | ratd | API compatibility |
| Proto stubs | All services | Regenerate with make proto |
| SDK | portal | Rebuild with make sdk-build |
| Postgres schema | ratd | Auto-migrated on startup |
Never run ratd version 2.2.0 with a runner at version 2.1.0. Version skew between services can cause gRPC protocol errors, data corruption, or silent behavior changes. Always upgrade all services together.