Rollback Migrations with Flyway Community Edition: A Clever Workaround

Flyway for freeloaders, rollback implemented in Python

Rollback Migrations with Flyway Community Edition: A Clever Workaround

Flyway Community Edition lacks the `undo` command, but you can still rollback migrations by writing reverse migrations with higher version numbers and using `migrate` to apply them. This approach records the last batch of applied migrations, stages synthetic 'down' scripts, and cleans up the schema history table via an `afterMigrate.sql` callback, all within a single transaction for atomicity. It's a hacky but effective solution that avoids the paid Teams license.

Basically an 'undo' expressed as `migrate`, and the database ends up back where it started.

More from this day

2026-08-29