-
Notifications
You must be signed in to change notification settings - Fork 290
Description
I had a situation with switching branches where the latest migration in the DB was "newer" than 2 migration files that had not yet been applied.
When running a "Down" migration, I noticed the "Up" code for both migrations was unintentionally applied and even worse they weren't recorded in the migrations table.
I tracked it down to the PlanMigration() function where it adds the results of ToCatchup(), regardless of the migration direction.
Obviously there a few issues with this. 1. They are up migrations when applying down. 2. The "catchup" migrations aren't considered in the check against the "max" parameter (which is 1 in my case). 3. The up migrations aren't recorded in the DB at all, leaving us in a broken state.
I'm not fluent in Go quite yet, otherwise I'd make a PR... but maybe the "catchup" logic should be ignored altogether for Down migrations.