mmk redo
Roll back then re-apply a migration in one step — the last applied, or a specific file.
bash
mmk redo [file] [options]Usage
bash
mmk redo # down + up the most recently applied migration
mmk redo <file> # down + up a specific migrationHow it works
mmk redo runs down() then up() for the target. It's the fast loop for iterating on a migration during development:
↩ Reverted 20260605120000-add-users-index.js [18ms]
✔ Applied 20260605120000-add-users-index.js [40ms]Options
| Option | Description |
|---|---|
[file] | Redo a specific migration file instead of the last applied one. |
--no-lock | Skip the concurrency lock. Dev only. |
--json | Emit the run results as a JSON array on stdout. |
Plus the global flags.
Notes
- The whole
down→upruns under a single lock acquisition, so no other process can interleave between the revert and the re-apply (and the migration can't be stranded in a reverted state if the re-apply fails to start). - The
downhalf is forced past the checksum guard — redoing an edited migration is the usual reason to runredo, so a drifted file does not block it. redoinherits the forward-only guard: an importedmigrate-mongorecord cannot be redone and is rejected up front.- Because the
downhalf reverts the record and theuphalf re-applies it, the audit trail keeps both events.
Exit codes
| Code | Meaning |
|---|---|
0 | The migration was reverted and re-applied. |
1 | Either half threw, or the target isn't applied / is irreversible. |