Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

storing more than 255 characters in a PostgreSQL DB on heroku

I am using heroku, and in doing so, am experiencing my first foray into postgresql. Maybe I just never came across it in development, but I am unable to save entries into my database that are longer than 255 characters. Is there a way around this? Currently the I am just using strings to store message data.

Secondly, if there is indeed a way to store more than 255 characters, is there a good way to convert my message strings into this form, using migrations? My app is currently live and in use.

Thanks!

like image 686
goddamnyouryan Avatar asked Nov 05 '10 02:11

goddamnyouryan


People also ask

What is the maximum size for a database in PostgreSQL?

PostgreSQL normally stores its table data in chunks of 8KB. The number of these blocks is limited to a 32-bit signed integer (just over two billion), giving a maximum table size of 16TB.

What is maximum length of character varying Postgres?

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.

Is Heroku Postgres good?

Heroku Postgres is an easy, low-cost way to get started with a relational database on the Heroku platform. This open-source database is also the most effective service for developers looking to build engaging apps.

Does PostgreSQL support Heroku?

Heroku Postgres is a managed SQL database service provided directly by Heroku. You can access a Heroku Postgres database from any language with a PostgreSQL driver, including all languages officially supported by Heroku.


1 Answers

use text instead of string on your migration type.


To change a migration

  1. script/generate migration change_string_to_text
  2. change_column :model, :attribute, :text
  3. rake db:migrate
like image 54
thenengah Avatar answered Oct 18 '22 03:10

thenengah