Run migrations and upgrade
SupaCloud uses sqlx numbered migrations in
server/migrations/. The server runs every pending migration automatically on
boot — you do not run migrations manually. This guide covers the safe upgrade
sequence: back up first, pull the new image, restart.
Before you start
Section titled “Before you start”-
You need write access to the host running the Docker Compose stack.
-
Confirm the stack is healthy before upgrading:
Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml psAll services should show
healthyorrunning. Do not upgrade a degraded stack.
1. Back up the PostgreSQL volume
Section titled “1. Back up the PostgreSQL volume”Database state lives in the postgres-data Docker volume. Back it up before
pulling a new image.
-
Stop the server (leave Postgres running so the dump is consistent):
Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml stop server -
Dump the database to a local file:
Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml \exec postgres \pg_dump -U supacloud supacloud \> supacloud-backup-$(date +%Y%m%d-%H%M%S).sqlReplace
supacloudwith yourPOSTGRES_USER/POSTGRES_DBvalues from.envif you changed them from the defaults. -
Verify the dump file is non-empty before continuing.
2. Pull the new image and restart
Section titled “2. Pull the new image and restart”-
Pull the new image:
Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml pull server -
Start the stack:
Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml up -dThe
serverservice waits for thepostgreshealth check, then runs all pending migrations before opening the HTTP port. Watch the log to confirm:Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml logs -f serverYou should see a line similar to:
Database migrations complete -
Confirm the stack is healthy:
Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml ps
What to do if a migration fails
Section titled “What to do if a migration fails”If the server exits with Migration failed: in its log:
-
Do not force-restart the server in a loop — each restart re-attempts the same migration and may leave the schema in a partial state.
-
Restore from the backup you took in step 1, then investigate the error before retrying:
Terminal window docker compose -f docker-compose.yml -f compose.standalone.yml \exec postgres \psql -U supacloud supacloud < supacloud-backup-YYYYMMDD-HHMMSS.sql -
Open an issue with the full migration error message and the migration filename (format:
NNN_description.sql).
Related
Section titled “Related”- Self-host with Docker Compose — initial setup
- Environment variables —
DATABASE_URLand other required variables - Secret provisioning — moving secrets out of
.env