db_migrate
Run explicit SQL schema migrations for SQL-mode projects. New projects use declared data: define tables and access rules in db/schema.ts and deploy raw source; db_migrate does not create their tables. docs({ topic: 'declared-data', section: 'declare-a-table-and-use-it' }) has a complete example. Managed projects refuse DDL with SCHEMA_LOCKED and apply no SQL.
For SQL-mode projects, CREATE TABLE, ALTER TABLE, CREATE INDEX and DROP are supported; multiple statements may be separated by ;. Explicit preview targeting changes only that preview database. Developer-only — app-user JWTs are rejected.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_id": "<project_id>",
"sql": "<sql>"
},
"name": "db_migrate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | DDL statements separated by semicolons. | |
| draft | No | Alias for the preview target flag. | |
| target | No | Database target. Preview requires preview_session_id (or draft_id). | |
| preview | No | Explicit preview target flag. Cannot be combined with a production target. | |
| draft_id | No | Alias for preview_session_id. | |
| preview_id | No | Optional expected preview candidate release id. | |
| production | No | Explicit production target flag. Cannot be combined with a preview target. | |
| project_id | Yes | Project ID (UUID), subdomain, or slug — resolved server-side, no UUID lookup needed. 'default' also works when the account has exactly one project; multi-project accounts must name one (the error lists them). | |
| preview_session_id | No | Identifier for an active preview session's isolated database. | |
| candidate_release_id | No | Alias for preview_id. |