开发者

LONGTEXT valid in migration for PGSQL and MySQL

开发者 https://www.devze.com 2023-02-09 17:56 出处:网络
I am developing a Ruby on Rails application that stores a lot of text in a LONGTEXT column. I noticed that when deployed to Heroku (which uses PostgreSQL) I am getting insert exceptions due to two of

I am developing a Ruby on Rails application that stores a lot of text in a LONGTEXT column. I noticed that when deployed to Heroku (which uses PostgreSQL) I am getting insert exceptions due to two of the column sizes being too large. Is there something special that must be done in order to get a tagged large text column type in PostgreSQL?

开发者_如何学运维

These were defined as "string" datatype in the Rails migration.


If you want the longtext datatype in PostgreSQL as well, just create it. A domain will do:

CREATE DOMAIN longtext AS text;

CREATE TABLE foo(bar longtext);


In PostgreSQL the required type is text. See the Character Types section of the docs.


A new migration that updates the models datatype to 'text' should do the work. Don't forget to restart the database. if you still have problems, take a look at your model with 'heroku console' and just enter the modelname.

If the db restart won't fix the problem, the only way I figured out was to reset the database with 'heroku pg:reset'. No funny way if you already have important data in your database.

0

精彩评论

暂无评论...
验证码 换一张
取 消