【问题标题】:heroku django south does not appear to use migrationsheroku django south 似乎没有使用迁移
【发布时间】:2013-09-01 03:22:33
【问题描述】:

我在 Django 南迁移时遇到了麻烦。这可能与我们的项目布局方式有关,但它之前运行良好,并且在本地运行良好。

我昨晚推送了新代码,其中包含my_app 应用程序中的迁移。所以在我当地的环境中...

$ ./manage.py migrate --list
socialaccount
(*) 0001_initial
(*) 0002_genericmodels
(*) 0003_auto__add_unique_socialaccount_uid_provider
(*) 0004_add_sites
(*) 0005_set_sites
(*) 0006_auto__del_field_socialapp_site
(*) 0007_auto__add_field_socialapp_client_id
(*) 0008_client_id
(*) 0009_auto__add_field_socialtoken_expires_at
(*) 0010_auto__chg_field_socialtoken_token
(*) 0011_auto__chg_field_socialtoken_token
payments
(*) 0001_initial
users
(*) 0001_initial
my_app
(*) 0001_initial
(*) 0002_auto__add_organizerapplication

在 heroku 中,它不会将 my_app 识别为具有迁移功能的应用。当我尝试迁移该应用时......

$ heroku run my_app/manage.py migrate my_app --app=my_app

Running my_app/manage.py migrate my_app attached to terminal... up, run.5016
The app 'my_app' does not appear to use migrations.
./manage.py migrate [appname] [migrationname|zero] [--all] [--list] [--skip] [--merge] [--no-initial-data] [--fake] [--db-dry-run] [--database=dbalias]

如果我列出迁移,您会注意到 my_app 未列出...

$ heroku run my_app/manage.py migrate --list --app=my_app

Running my_app/manage.py migrate --list attached to terminal... up, run.8264

socialaccount
(*) 0001_initial
(*) 0002_genericmodels
(*) 0003_auto__add_unique_socialaccount_uid_provider
(*) 0004_add_sites
(*) 0005_set_sites
(*) 0006_auto__del_field_socialapp_site
(*) 0007_auto__add_field_socialapp_client_id
(*) 0008_client_id
(*) 0009_auto__add_field_socialtoken_expires_at
(*) 0010_auto__chg_field_socialtoken_token
(*) 0011_auto__chg_field_socialtoken_token
payments
(*) 0001_initial
users
(*) 0001_initial

我不确定它是否相关,但当我检查时,my_app 列在我的INSTALLED_APPS 中。

更新

问题是缺少这个特定的迁移目录 __init__.py. 通过 Heroku 运行像 convert_to_south 这样的命令不会影响这一点,因为本地文件更改不会坚持。使用该文件再次推送 repo 可以识别迁移。然后我只需要假装第一次迁移就很好了。

【问题讨论】:

  • 我可能已经找到了解决方案。似乎推送到 heroku 的 my_app/migrations 目录缺少 init.py 文件。运行 convert_to_south 将创建,但是,这些文件不能使用 heroku 命令行放置到位。我相信仍然需要测试的解决方案是让 init 到位并推动改变。
  • 能否将您的更新移至答案并接受它,以便不再将其列为未回答的问题?

标签: python django heroku django-south


【解决方案1】:

确保在要迁移的应用程序的迁移文件夹中有一个 init.py 文件。 South 将在本地工作,但不会在 heroku 上进行生产。只需从您的一个应用程序中复制一个 init.py 文件,并将其放入您收到错误的应用程序的迁移文件夹中。将该更改推送到生产环境,然后迁移。

【讨论】:

  • Pstrazzulla 是正确的,如果没有检测到 init.py,sout 将无法告诉应用程序想被它管理。
猜你喜欢
  • 2012-08-16
  • 2011-08-14
  • 2012-04-26
  • 1970-01-01
  • 2012-05-23
  • 2012-08-06
  • 2012-08-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多