> ## Documentation Index
> Fetch the complete documentation index at: https://repost.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# repost schema migrate deploy

> Apply committed migrations to a live environment, with ancestry checks, a confirmed --force path, and --dry-run.

`repost schema migrate deploy` sends your migration history to an environment, which materializes its event-type registry and answers with the applied diff. It requires a clean local history and refuses any deploy that would lose deployed history.

## Usage

```bash theme={"languages":{"custom":["/languages/repost.json"]}}
repost schema migrate deploy [options]
```

## Options

| Option             | Description                                                                                             |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| `--dry-run`        | Print the deployment payload instead of sending it. Never touches the network.                          |
| `--force`          | Replace a diverged deployed history after showing exactly what will be replaced.                        |
| `--accept-replace` | Proceed without prompting when `--force` replaces. Only valid together with `--force`.                  |
| `--schema <path>`  | A `.repost` file or a directory of them. Defaults to `./repost/schema.repost`, else `./repost/schema/`. |

## Authentication

The command loads the workspace `.env` (next to or above the schema directory) and then reads:

| Variable         | Meaning                                                               |
| ---------------- | --------------------------------------------------------------------- |
| `REPOST_TOKEN`   | Required. An environment-scoped token with the `schema:deploy` scope. |
| `REPOST_API_URL` | Optional. Defaults to `https://api.repost.sh`.                        |

Values already set in the process environment win over `.env`.

## What it does

1. Validates the schema and builds the payload. No migrations, unmigrated changes, a fork, or a tampered snapshot each abort with instructions; run [`migrate dev`](/docs/cli/schema/migrate-dev) first.
2. Sends the head, the full lineage, and the accumulated JSON Schemas. The server applies it only when your head descends from the deployed one.
3. On refusal, the server's reason is printed: `client_behind` means pull the newer migrations and redeploy; `diverged` means merge and reconcile, or use `--force`.

With `--force`, the CLI first fetches the deployed head and prints what will be replaced (checksum, kind, migration name, deploy time), then asks `Replace the deployed history? [y/N]:`. In CI, pass `--accept-replace`. The reviewed head is sent back as a lease, so a deploy that lands in between makes the server refuse rather than overwrite unreviewed history. Forcing to a previously deployed checksum is the rollback path and prints an extra rewind warning. When `--force` turns out to be unnecessary, the CLI says so and performs a normal deploy.

Exit code `1` on any refusal, unconfirmed replacement, or server rejection.

## Examples

```bash theme={"languages":{"custom":["/languages/repost.json"]}}
repost schema migrate deploy
```

```text theme={"languages":{"custom":["/languages/repost.json"]}}
✔ deployment applied
  created: order.created
  updated: book.created
  archived: legacy.imported
```

Re-deploying the same head:

```text theme={"languages":{"custom":["/languages/repost.json"]}}
✔ already up to date
```

A refused deploy prints the server's reason:

```text theme={"languages":{"custom":["/languages/repost.json"]}}
error: deploy failed (409): deployed history is not an ancestor
  deployed head: sha256:9f2c...
  reason: diverged
```

## Continue

<Columns cols={3} className="gap-y-4">
  <Card title="push" icon="zap" href="/docs/cli/schema/push" cta="Dev loops" arrow="true">
    The migration-less alternative for development environments.
  </Card>

  <Card title="Migrations & deploys" icon="git-branch" href="/docs/send/deployments" cta="Concepts" arrow="true">
    Ancestry, forks, rollback, and non-destructive archival.
  </Card>

  <Card title="migrate status" icon="list-checks" href="/docs/cli/schema/migrate-status" cta="Pre-check" arrow="true">
    Verify the history is deployable before CI runs this.
  </Card>
</Columns>
