在heroku上的PostgreSQL数据库中存储超过255个字符 [英] storing more than 255 characters in a PostgreSQL DB on heroku

查看:132
本文介绍了在heroku上的PostgreSQL数据库中存储超过255个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是heroku,在这样做的时候,我体验了我第一次进入postgresql。也许我从来没有在开发过程中遇到它,但我无法将条目保存到长度超过255个字符的数据库中。有没有解决的办法?目前,我只是使用字符串来存储消息数据。其次,如果确实有一种方法可以存储超过255个字符,是否有一种很好的方法来转换我的消息字符串转换成这种形式,使用迁移?我的应用程序目前正在使用中。



谢谢! 使用文本而不是 / code>您的迁移类型。






更改迁移


  1. script / generate migration change_string_to_text

  2. change_column:模型,:属性,:text

  3. 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

  1. script/generate migration change_string_to_text
  2. change_column :model, :attribute, :text
  3. rake db:migrate

这篇关于在heroku上的PostgreSQL数据库中存储超过255个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆