MantisDocs

Rewind

Undo every write since a point in time, for a branch, a table or one row, and undo a migration.

Mantis records every write to every branch. A rewind uses that record to put things back the way they were at a time you name: rows inserted since then are removed, deleted rows are restored and changed rows get their old values back.

Preview first

npx shipmantis rewind --to 30m
Rewinding the branch to 2026-10-15T09:00:00.000Z undoes 42 changes:
  todos          3 removed, 12 restored, 27 reverted
Nothing was changed. Run again with --apply to rewind.

Without --apply nothing changes. Read the preview, then run the same command with --apply.

FlagWhat it does
--toA time with an offset, like 2026-10-14T09:30:00Z, or 30m, 2h, 1d ago.
--table <name>Rewind only this table.
--table <name> --id <uuid>Rewind only this row.
--branch <name>Rewind another branch. Default: MANTIS_BRANCH, else main.
--applyRewind after the preview.

Your agent does the same with the preview_rewind and rewind tools.

From PHP:

use Shipmantis\Mantis\Laravel\Facades\Mantis;

$preview = Mantis::previewRewind(now()->subMinutes(30));          // ['changes' => 42, ...]
$answer = Mantis::rewind(now()->subMinutes(30), table: 'todos');
$answer = Mantis::rewind('2026-10-25T14:02:00Z', table: 'invoices', id: $invoiceId);

if (isset($answer['change'])) {
    // held on main for a person's approval
}

Rewind covers the tables your migrations made and skips Laravel's migrations table. It goes no further back than the last migration or rollback. Rewinding one row by id needs a uuid id column.

Rewinding main

A rewind of main from the CLI or the agent is held for a person's approval, and the command exits with code 2. When it is approved it rewinds to the time that was asked for, so writes made while it waited are undone too. The dashboard shows the preview again before you approve.

A held rewind goes stale, and can't be approved, if the history it needs has aged out or the schema has changed since. A rewind started from the dashboard applies at once, since a person started it.

How far back

PlanHistory kept
Free7 days
Pro30 days

A rewind can't reach past a schema change either: undo the migration first, or rewind to a time after it.

Undo a migration

npx shipmantis undo

undo reverses the latest migration on the branch. A table or column it dropped comes back with its data, for as long as the plan keeps history. Run it again to undo the one before. An undo is never undone itself; to go forward again, push the schema.

On main, an undo that can lose data, such as dropping a table the migration created, is held for approval like a push.

Held changes

Every held change has a status. Your agent reads it with the check_change tool.

StatusMeans
pendingWaiting for a person in the dashboard.
approvedApproved and applied.
rejectedTurned down; nothing was changed.
staleCan no longer apply as asked, because the schema or the history moved on. Make the change again.

Examples

The agent ran a bad migration script. Find when it started, preview, apply:

npx shipmantis rewind --to 2026-10-25T14:02:00Z
npx shipmantis rewind --to 2026-10-25T14:02:00Z --apply   # on main: held for approval

One table got wiped. Leave the rest of the project alone:

npx shipmantis rewind --to 1h --table orders --apply

A user edited a row they shouldn't have. Put just that row back:

npx shipmantis rewind --to 2h --table invoices --id 0b6c2f7e-9d1a-4c3b-8e5f-6a7b8c9d0e1f --apply

Reset a test branch between runs instead of making a new one:

npx shipmantis rewind --branch e2e --to 10m --apply

Edge cases

CaseWhat happens
Writes from outside the SDKRecorded too: Mantis reads the database's write-ahead log, so a write over your own Postgres connection can be rewound like any other.
FilesNot rewound. Uploads and removals are outside the record; only table rows are.
A time before a schema changeRefused. Undo the migration first, or rewind to after it.
A time older than the plan keepsRefused: the history has aged out.
A new branchIts history starts when it was made.
Writes made while a rewind of main waits for approvalUndone too when it is approved, because it rewinds to the time that was asked for.

On this page