Fix: user email should be null instead of empty string

This commit is contained in:
Ilya Konanykhin
2017-01-31 23:46:10 +06:00
parent b8ba64ab93
commit 45e14a1070
3 changed files with 22 additions and 2 deletions
@@ -0,0 +1,15 @@
class UserEmailCanBeNull < ActiveRecord::Migration
def up
change_table :users do |t|
t.change :email, :string, default: nil, null: true
end
User.where(email: '').update_all(email: nil)
end
def down
change_table :users do |t|
t.change :email, :string, default: '', null: false
end
end
end