yogthos / migratus

MIGRATE ALL THE THINGS!
643 stars 93 forks source link

Duplicated migration caused destructive down migration #125

Closed platy closed 5 years ago

platy commented 6 years ago

We just had a situation where 2 identical migrations (add column) were added to a project, when the second one failed to apply, its down migration was run automatically (#111), removing a column and leaving the database inconsistent with the migrations.

I am now worried about the destructive potential of automatically applied down migrations, should we add a config option to control whether this is done - or is there another option?

yogthos commented 6 years ago

It would be possible to add an opt in option for turning off automatic rollback. However, when migrations are allowed to run partially that also introduces potential to leave the database in an inconsistent state.

platy commented 6 years ago

We will work on writing better migrations and testing them better, and consider adding the opt-in. In this case the rollback left the database in an inconsistent state, and with most of our migrations being atomic, an 'up' failing wouldn't usually be an issue.

Thanks for the speedy reply!