Maintenance Operations
This page describes the supported procedure for applying schema migrations and restarting Nitro Repo in a production environment.
Applying database migrations
Nitro uses SQL files under crates/core/migrations. To apply them manually:
- Back up the database using your standard tooling.
- Connect to Postgres with the same user Nitro runs under. Example using
psql:bashpsql "$DATABASE_URL" - Run the pending migration scripts in chronological order. Each migration consists of an
*.up.sqlfile. For example:bashRepeat for each newer migration. Keep the session open so you can roll back with the matching\i crates/core/migrations/20251115103000_repository_indexes.up.sql*.down.sqlif needed. - Verify with
SELECTor\dthat the new indexes/tables exist.
Tip: If you manage Postgres with a migration runner (e.g.,
sqlx-cliorjust migrate), use that wrapper instead of applying SQL manually.
Restarting Nitro Repo services
After migrations, rebuild and restart the services:
- Stop the running stack:bash
docker compose down - Rebuild (if code changed):bashor run
./dev.shnpm --prefix site run build && cargo build --features frontend - Start:bash
docker compose up -d - Check logs for migration output:bash
docker compose logs nitro_repo
Keep maintenance windows short: apply migrations first, then restart services once the schema is in place so requests hitting old binaries do not fail mid-migration.