@iamcalegari/mongoat / revertMigration
Function: revertMigration()
revertMigration(
database,version,config):Promise<void>
Defined in: src/migrate/runner.ts:589
Reverts a single applied migration via its down(ctx) export, removing its record from the control collection on success.
A migration with no down export is irreversible by design: this is checked BEFORE the control collection or the database connection is ever touched (guard-precondition-first) — revertMigration throws MIGRATION_IRREVERSIBLE purely from the on-disk module shape.
Acquires the same exclusive run lock as runMigrations/runTo once every precondition above has cleared, and releases it once the revert finishes (successfully or on failure).
Parameters
database
A Database instance (only required to be connected if the target migration turns out to be reversible).
version
string
The version to revert, YYYYMMDDHHMMSS.
config
MigrateConfig
Migration directory, control collection name, the allowNoTransaction opt-in, and an optional lockTtlMs.
Returns
Promise<void>
Throws
MIGRATION_NOT_FOUND when no migration file exists for version, or when it is not currently recorded as applied.
Throws
MIGRATION_IRREVERSIBLE when the migration has no down export.