Django+Postgres: “current transaction is aborted, commands ignored until end of transaction block”

后端 未结 9 1474
暖寄归人
暖寄归人 2020-12-12 11:39

I\'ve started working on a Django/Postgres site. Sometimes I work in manage.py shell, and accidentally do some DB action that results in an error. Then I am una

9条回答
  •  时光取名叫无心
    2020-12-12 12:02

    If you happen to get such an error when running migrate (South), it can be that you have lots of changes in database schema and want to handle them all at once. Postgres is a bit nasty on that. What always works, is to break one big migration into smaller steps. Most likely, you're using a version control system.

    • Your current version
    • Commit n1
    • Commit n2
    • Commit n3
    • Commit n4 # db changes
    • Commit n5
    • Commit n6
    • Commit n7 # db changse
    • Commit n8
    • Commit n9 # db changes
    • Commit n10

    So, having the situation described above, do as follows:

    • Checkout repository to "n4", then syncdb and migrate.
    • Checkout repository to "n7", then syncdb and migrate.
    • Checkout repository to "n10", then syncdb and migrate.

    And you're done. :)

    It should run flawlessly.

提交回复
热议问题