Data types in Ecto - "value is too long for character type (255)"

ERROR 22001 (string_data_right_truncation): value too long for character type changes (255)

I understand (and suggested) that the string will be limited to a certain number of characters; however, I'm not sure which type would be the best for this scenario.

What type should I use for the content section of a blog in a phoenix framework?

The data will be paragraphs of text and cannot be limited in size.

Thanks in advance.

+6
source share
2 answers

, varchar, , string .

255 , text . text , :

alter table(:posts) do
  modify :content, :text
end

string:

schema "posts" do
  field :content, :string
end
+12

, , . ( ), , . , PostgreSQL ( ), , bytea .

0

Source: https://habr.com/ru/post/1015776/


All Articles