Heroku git push DuplicateTable 的 Django 迁移失败

问题描述

背景

将 Django 应用从 Digital Ocean 迁移到 Heroku。我在迁移数据时遇到了问题,所以我使用 pg_dump 来获取每个表的架构和数据。然后在heroku中运行这些脚本。我加载了我的网站,我可以看到新的数据。

问题

现在,当我使用自动运行部署的 Heroku CLI 推送新代码时,由于以下原因而失败:psycopg2.errors.DuplicateTable: relation "django_content_type" already exists

我运行的命令是

git add .
git commit -m "some message"
git push heroku master"

procfile 具有运行命令的 release: python manage.py migrate,我曾考虑将其删除,但是当我将来要运行迁移时,这会导致问题。

有什么想法吗?

解决方法

今天早上这让我陷入了一个兔子洞,我想通了。由于我找不到类似的问题,我将把这个问题搁置一旁。

问题归结为本地和远程迁移不同步。按照这篇文章的最佳答案的说明解决了这个问题:Django Heroku Error "Your models have changes that are not yet reflected in a migration"