Add migration to set default values for contacts

This commit is contained in:
Muhsin Keloth
2023-05-12 09:43:54 +05:30
parent 020dcc4dc7
commit 7607752fdf
@@ -0,0 +1,13 @@
class SetDefaultNameToExistingContacts < ActiveRecord::Migration[7.0]
def change
Contact.where(name: nil).each do |contact|
contact.update(name: '')
end
end
def down
Contact.where(name: '').each do |contact|
contact.update(name: nil)
end
end
end