Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL string(255) limit - Rails, Ruby and Heroku

So I have a comments table that is structured like this:

# == 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) 

This is the error message I am getting:

ActiveRecord::StatementInvalid (PGError: ERROR:  value too long for type character varying(255) 

How do I store long text in a PG column using Rails 3.x and Heroku?

What would the migration look like to fix this issue?

Thanks.

like image 623
marcamillion Avatar asked Mar 20 '12 10:03

marcamillion


1 Answers

You would need to use text instead of string.

Migration would be something along the lines of:

change_column :comments, :body, :text, :limit => nil 
like image 74
Yule Avatar answered Sep 22 '22 15:09

Yule