运行 Django 测试给出“psycopg2.errors.DuplicateTable:关系已存在”错误
我从文本(sql)文件恢复了数据库:
psql ideatree < ideatree.sql
它没有错误。
运行迁移后,我启动了 Django 开发服务器,该网站运行良好。
但是当我运行测试时:
python manage.py test
我收到错误:
psycopg2.errors.DuplicateTable: relation "ideatree_colors" already exists
“ideatree_colors”是数据库中的一个表,但是测试正在创建自己单独的测试数据库,实际上在这个错误之后,测试数据库被留下了(我在再次运行测试之前将其删除) )。
我完全删除了集群,重新安装了 Postgresql-13,恢复了数据库,然后再次运行迁移。同样的错误。
I restored a database from a text (sql) file:
psql ideatree < ideatree.sql
which works with no errors.
After running migrations I bring up the Django development server and the site comes up fine.
But when I run tests:
python manage.py test
I get the error:
psycopg2.errors.DuplicateTable: relation "ideatree_colors" already exists
"ideatree_colors" is a table in the db, but test is creating its own separate test database, and indeed after this error the test database is left behind (I delete it before running tests again).
I completely dropped the cluster, re-installed Postgresql-13, restored the database, and ran migrations again. Same error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论