I am using heroku for a RoR application and am trying to manually set the length of a string column and am having trouble.
I tried making a migration along the lines of
change_column :posts, :content, :string, :length => 10000
I assumed this would work but no such luck, anyone have some pointers?
Thanks!
What is PostgreSQL Varchar datatype? In PostgreSQL, the Varchar data type is used to keep the character of infinite length. And it can hold a string with a maximum length of 65,535 bytes.
The maximum limit of size character using character varying data type in PostgreSQL is 10485760. The below example shows that the size of the character using character varying data type in PostgreSQL is 10485760.
The notations varchar( n ) and char( n ) are aliases for character varying( n ) and character( n ) , respectively. character without length specifier is equivalent to character(1) . If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension.
The length limit option in Rails migrations is called :limit
:
change_column :posts, :content, :string, :limit => 10000
If you are finding yourself changing VARCHAR
length limits a lot, you might want to read @depesz's blog post on VARCHAR
vs TEXT
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With