goose down: Roll Back One Migration
goose <driver> <dsn> down reverts the single most recently applied migration using its down block.
goose down undoes one migration at a time. down-to <version> unwinds back to a specific version.
What it does
goose down runs the down section of the current migration and decrements goose_db_version. down-to VERSION reverts repeatedly until the database is at that version. reset reverts all migrations.
Common usage
# revert the last migration
goose -dir ./migrations postgres "$GOOSE_DSN" down
# revert down to a specific version
goose -dir ./migrations postgres "$GOOSE_DSN" down-to 20240101120000Options
| Arg / flag | What it does |
|---|---|
| down | Revert the most recent migration |
| down-to <version> | Revert down to (and including above) a version |
| reset | Revert every applied migration |
| -dir <dir> | Migrations directory |
In CI
Each goose down step reverts exactly one migration, so a scripted rollback of several needs a loop or down-to. A down block that drops columns or tables destroys data; use rollbacks as recovery, and prefer redeploying a forward fix in normal pipelines.
Common errors in CI
"ERROR ... failed to run SQL migration" during down means the down block itself failed, often because it assumes objects that no longer exist. "no migration found" from down-to means the target version is not a real migration timestamp. A missing down section (a Go migration with only Up) makes down a no-op or an error.