Help us understand the problem. What is going on with this article?

RailsのMigrationでstringからtextに変更する

More than 3 years have passed since last update.

普通にこんなかんじでいけた。

db/migrate/20161019222407_change_events_memo_to_text.rb
class ChangeEventsMemoToText < ActiveRecord::Migration
  def up
    change_column :events, :memo, :text, default: nil
  end

  def down
    change_column :events, :memo, :string
  end
end

最初 default: nil をつけていなかったが、下記のようなエラーが出たので default: nil をつけてみたら普通に通った。

Mysql2::Error: BLOB, TEXT, GEOMETRY or JSON column 'memo' can't have a default value: ALTER TABLE `events` CHANGE `memo` `memo` text DEFAULT '' NOT NULL
m3dev
インターネット、最新IT技術を活用し日本・世界の医療を改善することを目指します
https://m3.recruitment.jp/engineer/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away