Skip to content

Instantly share code, notes, and snippets.

@ocxo
Created October 23, 2014 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocxo/8b7c907158d8c6e5a812 to your computer and use it in GitHub Desktop.
Save ocxo/8b7c907158d8c6e5a812 to your computer and use it in GitHub Desktop.
users = User.where("data @> hstore('first_name', null) or data @> hstore('last_name', null)")
users.each do |u|
u.first_name = "First" if u.first_name.blank?
u.last_name = "Last" if u.last_name.blank?
u.save(validate: false)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment