Say I have a db table called fruit like this:
id name
1 ““
2 “"
3 ““
4 ““
5 ""
6 melon
I need to write a migration to change the empty strings to null without affecting melon
in this case.
Would it be something on these lines?
def change
update_column fruits, :name, null if :name => ""
end
Pretty basic stuff I guess but I'm kinda stuck here. What is the best approach here?