Don P
Don P

Reputation: 63728

Altering character limit on Heroku PostGRES doesn't change column in database

In my Heroku postgres db, I had a column of type "string" with a limit of "50" characters.

I just made a migration that changed the limit to 80 characters.

class ChangeTagLineLimit < ActiveRecord::Migration
  def up
    change_column :blocks, :tag_line, :string, :limit => 80
  end
  def down
    change_column :blocks, :tag_line, :string, :limit => 50
  end
end

However when I try to save a record, I get this error:

PG::StringDataRightTruncation: ERROR: value too long for type character varying(50)

It sounds like PostGRES hasn't changed the size of the varchar column. How do I fix this?

Upvotes: 1

Views: 260

Answers (1)

tokoph
tokoph

Reputation: 118

That migration should work. The error is probably related to another table that didn't get migrated yet.

Upvotes: 1

Related Questions