I have a pretty long data migration that I\'m doing to correct an earlier bad migration where some rows were created incorrectly. I\'m trying to assign values to a new column b
Each migration is wrapped around one transaction, so when something fails during migration, all operations will be cancelled. Because of that, each transaction in which something failed, can't take new queries (they will be cancelled anyway).
Wrapping some operations with with transaction.atomic():
is not good solution, because you won't be able to cancel that operation when something will fail. Instead of that, avoid integrity errors by doing some more checks before saving data.