Database migrations

Create, apply and check migrations with the robotelos CLI, and the rules that keep them safe.

Robotelos keeps its PostgreSQL schema in versioned, checksummed migration files under db/migrations/. The robotelos CLI applies them.

Commands

go run ./runtime/cmd/robotelos db migrate new create_employees   # empty, timestamped file
go run ./runtime/cmd/robotelos db migrate status                 # applied, pending or changed
go run ./runtime/cmd/robotelos db migrate up                     # apply what is pending

up and status read the connection string from ROBOTELOS_DATABASE_URL. The migrations directory defaults to db/migrations relative to the working directory; ROBOTELOS_MIGRATIONS_DIR or --dir changes it. Build the CLI with go build -o robotelos ./runtime/cmd/robotelos if you run it often.

Rules

  • Never edit an applied migration. The runner records a checksum for each applied version. A changed file makes up refuse to run. Add a new file instead.
  • File names are YYYYMMDDHHMMSS_what_it_does.sql. The timestamp is the version. Two files with one version are refused.
  • Each migration runs in one transaction together with its version row. A file whose first line is -- robotelos:online runs outside a transaction, for CREATE INDEX CONCURRENTLY; such a file must be safe to run twice.- Concurrent migrators take turns. An advisory lock serializes them.

Current migrations

FileContent
20261113120000_durable_dispatch.sqlExecutions, execution events and the dispatch outbox
20261113120100_conversations.sqlConversations, journal, membership, receipts, pending approvals, home-account index
20261113120200_roles_and_rls.sqlrobotelos_app and robotelos_worker, grants, row level security
20261113120300_agent_turns.sqlThe agent turn queue
20261113120400_execution_rls.sqlRow level security for the execution tables and the split of duties between the two roles

robotelos db migrate status lists the files and their state in your database.

Next steps