简体   繁体   English

django 测试期间数据库创建失败

[英]Database creation failing during django testing

I have a functional Django project with a functional database.我有一个带有功能数据库的功能 Django 项目。 When I try to run tests on this project, I get this error during database creation:当我尝试在此项目上运行测试时,在创建数据库期间出现此错误:

django.db.utils.InternalError: (1553, "Cannot drop index 'One response per question per level': needed in a foreign key constraint")

I had a unique_together constraint in one of the tables which I later removed.我在后来删除的其中一个表中有一个 unique_together 约束。

This line这条线

'One response per question per level'

is related to that unique_together constraint and is present in two migration files - first time during the creation of the table and second time during the removal.与 unique_together 约束相关,并存在于两个迁移文件中 - 第一次是在创建表期间,第二次是在删除期间。

When I run the tests, it is throwing this error and the database is not getting created.当我运行测试时,它抛出这个错误并且数据库没有被创建。 How can I solve this problem?我怎么解决这个问题?

This seems like a known problem in Mysql code.djangoproject.com/ticket/24757这似乎是 Mysql code.djangoproject.com/ticket/24757 中的一个已知问题

I'm using this workaround for now.我现在正在使用此解决方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM