relay migrate
Apply Restaq's database migrations, for whichever dialect your relay.ts uses.
Apply Restaq's schema to your database — Postgres, SQLite, or MySQL, whichever client your relay.ts configures.
Usage
relay migrate [--dir <path>]--dir points at the directory containing relay.ts — it defaults to the current working directory.
Requirements
- A
relay.tsin the target directory, exportingrelay(see relay init) - Nothing else —
relay migrateloads yourrelay.tsdirectly and calls itsmigrate()method, so whatever database client you configured there is what gets migrated. NoDATABASE_URLor other env var is read by the CLI itself.
What it does
Creates three tables, named to match whichever dialect you're using:
- restaq_executions — one row per execution, tracking status, attempt, timestamps, and event data
- restaq_execution_steps — append-only step history; a step that failed and later succeeded stores both attempts
- restaq_execution_logs — interleaved logs from the runtime and handler
A restaq_migrations tracking table records which migrations have already applied, so re-running relay migrate is always safe.
Example
relay migrateOutput:
Applying Restaq migrations...
Migrations applied.From another directory:
relay migrate --dir path/to/appWhen you actually need this
Outside production, migrations apply automatically the first time your relay processes an event — you don't need to run this command in local development at all. In production, run it explicitly before scaling up new instances (e.g. as a step in your deploy pipeline), since concurrent instances booting at the same time could otherwise race on the same schema changes.
Idempotency
Running relay migrate multiple times is safe — it won't re-create tables or lose data. Useful in CI/CD pipelines.
Troubleshooting
Error: "Could not find relay.ts"
- Confirm
relay.tsexists in the directory you're running from, or pass--dir
A connection error from your database driver
- Check the connection details passed to your database client in
relay.ts(e.g.DATABASE_URLif that's what you wired it to read) - Verify the database server is running and reachable
See Database for setup details per dialect.