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
uprefuse 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:onlineruns outside a transaction, forCREATE INDEX CONCURRENTLY; such a file must be safe to run twice.- Concurrent migrators take turns. An advisory lock serializes them.
Current migrations
| File | Content |
|---|---|
20261113120000_durable_dispatch.sql | Executions, execution events and the dispatch outbox |
20261113120100_conversations.sql | Conversations, journal, membership, receipts, pending approvals, home-account index |
20261113120200_roles_and_rls.sql | robotelos_app and robotelos_worker, grants, row level security |
20261113120300_agent_turns.sql | The agent turn queue |
20261113120400_execution_rls.sql | Row 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
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.