![](/img/trans.png)
[英]PG::StringDataRightTruncation: ERROR: PostgreSQL string(255) limit | Heroku
[英]PostgreSQL string(255) limit - Rails, Ruby and Heroku
所以我有一個comments
表,結構如下:
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# body :string(255)
# notified :boolean
# user_id :integer
# stage_id :integer
# created_at :datetime
# updated_at :datetime
# client_id :integer
# author :string(255)
這是我收到的錯誤消息:
ActiveRecord::StatementInvalid (PGError: ERROR: value too long for type character varying(255)
如何使用Rails 3.x和Heroku在PG列中存儲長文本?
遷移將如何解決此問題?
謝謝。
您需要使用文本而不是字符串。
遷移將有以下幾點:
change_column :comments, :body, :text, :limit => nil
我一直通過這種類型的查詢來解決這個問題
ALTER TABLE your_table_name ALTER COLUMN your_column_name TYPE text;
變化的字符長度有限,你不能通過這個長度。
text是一個沒有限制的變量。
因此,您可以將列類型從字符變化(具有長度)轉換為
文字(沒有限制)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.