[ACCEPTED]-storing more than 255 characters in a PostgreSQL DB on heroku-heroku
use text
instead of string
on your migration type.
To 1 change a migration
script/generate migration change_string_to_text
change_column :model, :attribute, :text
rake db:migrate
Just to expand on @Codeglot's answer, :text
is 11 for (essentially) unlimited-length strings. :string
with 10 a limit:1234
option will limit the string to that 9 length. On Postgres, a :string, limit:nil
is effectively 8 synonymous with :text
. Although some databases 7 store VARCHAR, VARCHAR(n), and TEXT types 6 in different ways, leading to performance 5 considerations, Postgres stores them all 4 in the same way.
So if you want to exceed 3 255 chars but not be completely unbounded, you can 2 use :string, limit:1234
. Alternatively, you can use :text
and restrict 1 the length via validations.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.