Ruby on Rails で MySQL を利用している時に、マイグレーションのデータ型を「text」にすると、その列に65535バイトまでしかデータを入れられない。
This entry was posted by fumiu on 2009年11月27日 at 11:04 AM under MySQL, Ruby. Tagged rails.
You can leave a response, or trackback from your own site. Follow any responses to this entry through the RSS 2.0 feed.
require 'active_record/connection_adapters/mysql_adapter'
if connection.kind_of?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
execute "ALTER TABLE table CHANGE COLUMN col col mediumtext"
end
fumiu says:
以下のrequireを先頭に入れ、マイグレーション本文で下の3行を参考にテーブル変更のSQLを実行させると、より多くの文字数を入力できます。
2009年11月27日, 11:13 AMmediumtext では最大 1677215 文字まで、largetext ならば最大 4294967295 文字まで入ります。