Can't execute queries until end of atomic block in my data migration on django 1.7

后端 未结 3 502
别那么骄傲
别那么骄傲 2021-02-07 12:42

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

3条回答
  •  心在旅途
    2021-02-07 13:08

    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.

提交回复
热议问题