简体   繁体   English

Heroku git 推送 Django DuplicateTable 迁移失败

[英]Heroku git push Django migration failure for DuplicateTable

Background背景

Migrating a Django app from Digital Ocean to Heroku.将 Django 应用程序从 Digital Ocean 迁移到 Heroku。 I had problems migrating the data, so I used pg_dump to get the schema and the data of each table.我在迁移数据时遇到了问题,所以我使用 pg_dump 来获取每个表的架构和数据。 Then ran those scripts in heroku.然后在 heroku 中运行这些脚本。 I loaded my website and I can see the new data coming through.我加载了我的网站,我可以看到新数据通过。

Problem问题

Now when I push new code with the Heroku CLI that auto runs the deployment, it fails for this reason: psycopg2.errors.DuplicateTable: relation "django_content_type" already exists现在,当我使用自动运行部署的 Heroku CLI 推送新代码时,它因此失败: psycopg2.errors.DuplicateTable: relation "django_content_type" already exists

The commands I run are我运行的命令是

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

The Procfile has release: python manage.py migrate which runs the commands, which I thought about taking it out but when I have migrations to run in the future this will cause an issue. Procfilerelease: python manage.py migrate运行命令,我曾想过将其取出,但是当我将来要运行迁移时,这将导致问题。

Any thoughts?有什么想法吗?

This sent me down a rabbit hole this morning, and I figured it out.今天早上这让我掉进了一个兔子洞,我想通了。 I am going to leave the question up since I could not find a similar one.因为找不到类似的问题,所以我将把这个问题搁置一旁。

The issue came down to migrations being out of sync locally and remotely.问题归结为本地和远程迁移不同步。 Following the instructions for the top answer on this post cleared up the issue: Django Heroku Error "Your models have changes that are not yet reflected in a migration"按照这篇文章的最佳答案的说明清除了问题: Django Heroku 错误“您的模型有尚未反映在迁移中的更改”

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

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