Local stack and database

The robotelos commands that run a local instance with Docker (dev) and manage PostgreSQL migrations (db).

Local stack: dev

robotelos dev runs a complete instance on your machine for testing. It needs Docker.

CommandWhat it does
robotelos dev doctorChecks Docker, the config file, the state folder and the ports. Lists every failure. Exit code 1 if anything fails.
robotelos dev upStarts PostgreSQL in Docker, applies the migrations and runs the gateway. Ctrl-C stops the gateway and keeps the database.
robotelos dev statusShows the state of the database container.
robotelos dev downRemoves the database container. Add --volumes to delete its data too.

dev up accepts these flags:

FlagDefaultMeaning
-http127.0.0.1:8787HTTP address of the gateway (SSE and WebSocket)
-grpc127.0.0.1:8788gRPC address; off disables it
-postgres-port5433Host port for PostgreSQL
-context-namedevName of the context that dev up registers and makes current

The token for the local instance is written to ~/.robotelos/dev/token. The generated secrets are kept in ~/.robotelos/dev/state.json, readable by you only.

Database: db migrate

CommandWhat it does
robotelos db migrate statusLists each migration as applied, pending or changed.
robotelos db migrate upApplies the pending migrations. Refuses if an applied file has changed.
robotelos db migrate up --dry-runRuns the pending migrations in a transaction and rolls it back, so you can check them.
robotelos db migrate new NAME --dir CHAINCreates an empty, timestamped migration file in the chain you name (db/migrations, db/control/migrations or db/data/migrations).
robotelos db rotate-epoch --yesAfter the control database was restored to an earlier point, starts a new epoch of its desired state, so that every fleet takes the snapshot it is given next whatever its revision. Reads ROBOTELOS_DATABASE_URL, the control database.
robotelos db migrate repair --status applied|reverted --yes VERSIONFixes the version table after a manual change. Runs no SQL; refuses a changed file.

up, status and --dry-run read the database address from ROBOTELOS_DATABASE_URL. This keeps the password out of the command line. Use --dir or ROBOTELOS_MIGRATIONS_DIR to choose another migrations folder.

Next steps