class ChangeNameNotNullInUsers < ActiveRecord::Migration
  def up
    change_column :users, :name, :text, null: false
  end

  def down
    change_column :users, :name, :text, null: true
  end
end

class ChangeNameNotNullInUsers < ActiveRecord::Migration
  def up
    User.where(name: nil).each do |user|
      user.update name: user.email
    end
    change_column :users, :name, :text, null: false
  end

  def down
    change_column :users, :name, :text, null: true
  end
end

Change migration to avoid setting a "not null" constraint on the name column while some records still have a null value there.
Change migration to avoid setting a "not null" constraint on the name column while some records still have a null value there.

This should fix a MySQL error while deploying.
