我正在使用db:push
将我的数据库从 sqlite 转换为 postgres 将我的 Django 应用程序的数据库上传到 Heroku。
但是,在此过程中我收到错误:
Taps Server Error: PGError: ERROR: integer out of range
当我尝试使用在 Heroku 的服务器上创建一个干净的数据库时python manage.py syncdb
,我收到了类似的消息:
Installing index for django_openid.UserOpenidAssociation model
Installing json fixture 'initial_data' from '/app/.heroku/venv/lib/python2.7/site- packages/oembed/fixtures'.
Installing json fixture 'initial_data' from '/app/.heroku/venv/lib/python2.7/site- packages/pinax/apps/photos/fixtures'.
Installing json fixture 'initial_data' from '/app/store/fixtures'.
Problem installing fixture '/app/store/fixtures/initial_data.json': Traceback (most recent call last):
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 169, in handle
obj.save(using=using)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/serializers/base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/base.py", line 501, in save_base
rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/query.py", line 491, in _update
return query.get_compiler(self.db).execute_sql(None)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 861, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 727, in execute_sql
cursor.execute(sql, params)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/util.py", line 15, in execute
return self.cursor.execute(sql, params)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
return self.cursor.execute(query, args)
DatabaseError: value too long for type character varying(50)
在我看来,问题在于初始数据,但并不完全确定。我在这里发现了一篇文章,说这可能是字段编码的问题,但即使我要调查,也不完全确定如何阅读错误消息以找出导致问题的确切原因并查明哪个表/column 可能会导致问题。