让SQLite数据库中表名支持重命名的方法

Posted Jerome12138

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了让SQLite数据库中表名支持重命名的方法相关的知识,希望对你有一定的参考价值。

修改了数据库表名之后,更新数据库时跳错:

django.db.utils.NotSupportedError: Renaming the ‘app_class‘ table while in a transaction is not supported on SQLite because it would break referential integrity. Try adding atomic = False to the Migration class.

意思就是 SQLite 数据库不支持重命名的操作,添加atomic = False即可:

Migration 在 py36Libsite-packagesdjangodbmigrationsmigration.py 的位置

atomic = True 改成 atomic = False

以上是关于让SQLite数据库中表名支持重命名的方法的主要内容,如果未能解决你的问题,请参考以下文章