【问题标题】:django doesnt run a specific migration (it skipped) in productiondjango 在生产中没有运行特定的迁移(它跳过)
【发布时间】:2022-01-12 06:52:46
【问题描述】:

当我运行 makemigrations 时它返回

  users/migrations/0002_remove_profile_image.py
    - Remove field image from profile

但是当我运行migrate users 0002.. 时,它说CommandError: Cannot find a migration matching '0002_remove_profile_image.py' from app 'users'

当我运行migrate 时,它说

No migrations to apply.
  Your models in app(s): 'users' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

我能做什么? 我在 Heroku 上部署

【问题讨论】:

  • 删除.py,所以只需migrate users 0002_remove_profile_image或简单migrate users 0002
  • 您提交迁移了吗? 始终将迁移提交到您的版本控制。我们不应该在服务器本身上生成迁移文件。此外,您的文件在 Heroku 上是短暂的,这意味着它们仅在 pod 存在之前存在(这可能是正在发生的事情)。

标签: python django heroku django-migrations


【解决方案1】:

您似乎正在使用带有.py 的迁移名称:

./manage.py migrate users 0002_remove_profile_image.py

但正确的用法是没有它,所以删除它:

./manage.py migrate users 0002_remove_profile_image

或者只是简写:

./manage.py migrate users 0002

【讨论】:

    【解决方案2】:

    对不起,我的错。我用heroku run 运行我应该先在本地运行。

    【讨论】:

      猜你喜欢
      • 2017-06-24
      • 2022-12-01
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-14
      • 2021-08-30
      • 1970-01-01
      相关资源
      最近更新 更多