2012-07-02 26 views
0

我正在使用db:push將我的數據庫從sqlite轉換爲postgres,將我的Django應用程序的數據庫上傳到Heroku。將sqlite數據庫轉換爲postgres產生DatabaseError:值太長,因爲字符變化(50)

但是,過程中我得到的錯誤:

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) 

它看起來問題在於最初的數據,但不完全確定。我在這裏發現了一篇文章,說這可能是一個字段編碼的問題,但即使我正在研究那些不完全確定如何讀取錯誤信息以找出究竟是什麼導致了問題,還要找出哪個表/列可能會導致問題。

+0

你有你的sqlite數據庫的DDL嗎?怎麼樣postgresql數據庫?你也可以發佈這個嗎? – swasheck

回答

2

DatabaseError: value too long for type character varying(50)意味着您試圖將超過50個字符的字符串存儲到VARCHAR(50)類型中。您可以通過查看CharField s,使用max_length=50SlugField s(默認爲max_length=50)來查看潛在候選人。然後,查看您的initial_data.json燈具,看看是否有任何明顯長的字符串被存儲用於任何這些字段。

+0

感謝您的建議......我指出了這個問題 - 但它並沒有解決推送期間原始的「Taps服務器錯誤:PGError:ERROR:整數超出範圍」。我猜這是不相關的,所以我會發佈一個單獨的問題。 – user1328021

0

正如@ChrisPratt所說,我有同樣的問題,但無法弄清楚問題所在。我的項目中只有一個應用程序,我刪除了應用程序的遷移文件夾中的* py文件(init .py文件除外),並清除了我sqlite3數據庫中的所有表(我當時沒有任何重要數據)然後運行migrate命令。有效!。

相關問題