在heroku上的PostgreSQL数据库中存储超过255个字符 [英] storing more than 255 characters in a PostgreSQL DB on heroku
问题描述
我使用的是heroku,在这样做的时候,我体验了我第一次进入postgresql。也许我从来没有在开发过程中遇到它,但我无法将条目保存到长度超过255个字符的数据库中。有没有解决的办法?目前,我只是使用字符串来存储消息数据。其次,如果确实有一种方法可以存储超过255个字符,是否有一种很好的方法来转换我的消息字符串转换成这种形式,使用迁移?我的应用程序目前正在使用中。
谢谢! 使用文本
而不是
更改迁移
-
script / generate migration change_string_to_text
-
change_column:模型,:属性,:text
-
rake db:migrate
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!
use text
instead of string
on your migration type.
To change a migration
script/generate migration change_string_to_text
change_column :model, :attribute, :text
rake db:migrate
这篇关于在heroku上的PostgreSQL数据库中存储超过255个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!