migrations

Generate a SQL migration script from a free-text intent

Parse a plain-English migration intent (e.g. 'add index on positions(deviceid, fixtime desc)') and emit dialect-correct up + down SQL plus warnings. Never executes — output is for the caller to review and run manually. Costs 1 quota unit per call. Build tier (or higher) required.

post/v1/migrations/generate

Request

  • Base URL: https://data.thinair.co
  • URL: https://data.thinair.co/v1/migrations/generate
  • Auth: API key in header x-api-key

Request body

connectionstring

Connection name (display) or id (uuid). When omitted, the tenant's default (first added) connection is used. Same fallback as the MCP generate_migration tool.

intentstring required

Plain-English description of the migration. Examples: 'add soft delete to drivers', 'add index on trips(driver_id, created_at)', 'rename email to email_address on drivers'. Phrasing matters: name the table, the column, and the action explicitly — the intent parser extracts those three and will reject a request it cannot resolve rather than guess.

target_dialect'postgres' | 'mysql' | 'mssql'

Optional target dialect. The handler currently derives dialect from the resolved connection — this hint is informational only and reserved for future cross-dialect translation. Mismatches between hint and resolved dialect surface in response meta but don't override.

dry_runboolean

Reserved for future support. The current handler NEVER executes the generated SQL — it only emits up + down strings — so dry_run is effectively always true. Echoed in response meta when set.

Example request

{
  "connection": "fleet",
  "intent": "add nullable notes column to vehicles"
}

Response

Generated migration. Always review data.warnings[] before running — some operations (drop column, create unique index) are destructive or fail when constraints aren't met.

dataobject required
displayobject required
summarystring
insightsobject[]
metaobject required

Changes

No recorded changes to this operation across all 1 revision of this API.