We're using Golang Migrate which I generally love but recently it's just seemed like I can never actually run the migrations so I end up manually applying the migrations and "fixing" the schema_migrations
table. There is always some error. Here's the example that's happening now as I understand it.
Dev tries to roll forward and gets: no change
. So dev tries to roll back N migrations and gets:
error: migration failed in line 0: ALTER TABLE `table_name` DROP `column`;
(details: Error 1091: Can't DROP 'column'; check that column/key exists)
I believe the issue is there are two branches one we'll call "slow" and one we'll call "quick". So "slow" gets started but as it's name implies it just takes a long time to get to production. Meanwhile quick has no such problem and gets merged weeks before "slow". When dev goes to roll forward because the "quick" branch was started after "slow" they get no change
. To compensate dev attempts to roll back a few migrations so the new migrations can be applied but bumps into SQL errors because the column never got created because that specific migration never rolled forward.
Is the "fix" for this that the migrations are written more defensively (ex: using IF EXISTS
)? Are other people not bumping into these issues? TIA.
golang-migrate: v4.15.2
MySQL: 5.7.34-log