---
title: "Apply the live capsule's schema migrations"
method: POST
path: "/v1/spaces/{spaceId}/db/migrate"
tags: ["Database"]
---

# Apply the live capsule's schema migrations

`POST /v1/spaces/{spaceId}/db/migrate`

## Request

- Base URL: `https://api.spacefast.com`
- URL: `https://api.spacefast.com/v1/spaces/{spaceId}/db/migrate`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer

Re-runs the live capsule's stored migration plan against the space's MySQL. Use this route to retry a plan that failed during publish. This route is Zero-kind only. A worker declares no schema, and a static version has no database. An empty plan queues nothing.

## Path parameters

- `spaceId` string, required

## Response `200`

Response for status 200

- object
  - `$schema` string, uri: Canonical JSON Schema URL for this response body. The server also sends it in the `Link: rel="describedby"` response header.
  - `data` object, required
    - `versionId` string, required: Live version whose migration plan this is.
    - `runtimeKind` 'zero', required
    - `schemaHash` string, nullable, required
    - `mode` 'safe' | 'drop' | 'rename', nullable, required
    - `operations` union[], required: The plan the live capsule declared, in the order it applies.
      - union
        - object
          - `op` 'create_table', required
          - `table` string, required
        - object
          - `op` 'add_column', required
          - `table` string, required
          - `column` object, required
            - `name` string, required
            - `type` 'string' | 'boolean' | 'number' | 'json', required
            - `nullable` boolean, required
            - `optional` true
            - `userReference` true
            - `default` unknown
        - object
          - `op` 'add_index', required
          - `table` string, required
          - `name` string, required
          - `columns` string[], required
          - `unique` boolean, required
        - object
          - `op` 'drop_index', required
          - `table` string, required
          - `name` string, required
          - `explicit` 'drop', required
        - object
          - `op` 'drop_table', required
          - `table` string, required
          - `explicit` 'drop', required
        - object
          - `op` 'drop_column', required
          - `table` string, required
          - `column` string, required
          - `explicit` 'drop', required
        - object
          - `op` 'rename_table', required
          - `from` string, required
          - `to` string, required
          - `explicit` 'rename', required
        - object
          - `op` 'rename_column', required
          - `table` string, required
          - `from` string, required
          - `to` string, required
          - `explicit` 'rename', required
    - `queued` boolean, required: Whether runtime finalize was queued to apply the plan. `false` when the plan is empty because there is nothing to run.
  - `operation` object, nullable, required: Background operation handle when asynchronous work remains after this mutation; null when it completed synchronously.
    - `id` string, required
    - `kind` string, required
    - `status` 'queued' | 'running' | 'succeeded' | 'failed' | 'canceled', required
    - `resources` object[], required
      - `type` string, required
      - `id` string, required
    - `progress` object
      - `total` integer, required
      - `completed` integer, required
      - `failed` integer, required
    - `diagnostics` object[]
      - `code` string, required: Stable snake_case diagnostic code naming the public contract that produced it.
      - `severity` 'info' | 'warning' | 'error', required: How actionable the diagnostic is.
      - `message` string, required: Human-readable explanation with enough detail to act on.
      - `path` string, nullable: Artifact path the diagnostic points at, for example "_headers:12", when one exists.
      - `provider` 'infra' | 'dns' | 'registrar' | 'runtime', nullable: Upstream system the diagnostic originated from, when not Spacefast itself.
      - `details` object, nullable: Machine-readable context for the diagnostic code.
      - `fix` string, nullable: Concrete, agent-actionable remediation hint, when one can be derived.
      - `retryable` boolean, nullable: Whether retrying the same operation can resolve this diagnostic without the caller changing anything.
    - `createdAt` string, date-time, required
    - `finishedAt` string, date-time

## Other responses

- `default`: Problem details (RFC 9457). Any 4xx/5xx response is one `application/problem+json` document.

---

[API](https://skmtc.dev/spacefast/apis/spacefast-api.md) · [All operations](https://skmtc.dev/spacefast/apis/spacefast-api/llms.txt) · [OpenAPI document](https://skmtc.dev/spacefast/apis/spacefast-api/revisions/bd165bc7c983?raw)
