【发布时间】:2012-07-03 00:34:41
【问题描述】:
我正在使用 db:push 将我的 Django 应用程序的数据库上传到 Heroku,这会将我的数据库从 sqlite 转换为 postgres。
然而,在这个过程中我得到了错误:
Taps Server Error: PGError: ERROR: integer out of range
当我尝试使用 python manage.py syncdb 在 Heroku 的服务器上创建一个干净的数据库时,我收到了类似的消息:
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 可能会导致问题。
【问题讨论】:
-
你有你的 sqlite 数据库的 DDL 吗? postgresql 数据库怎么样?你也可以发一下吗?
标签: django sqlite postgresql heroku