Skip to content

Instantly share code, notes, and snippets.

@rolfschmidt
Created April 23, 2024 10:46
Show Gist options
  • Select an option

  • Save rolfschmidt/e86a4c049dc2ed0c81df4322acd22ef1 to your computer and use it in GitHub Desktop.

Select an option

Save rolfschmidt/e86a4c049dc2ed0c81df4322acd22ef1 to your computer and use it in GitHub Desktop.
prod_mode = false
if ARGV[0].present?
prod_mode = true
puts "PROD MODE ON!!!"
sleep 2
end
Store.where("o_id LIKE '%.0'").find_each do |st|
nv = st.o_id.sub(/\.0$/, '')
puts "Change store object #{st.id} (#{st.store_object.name}) o_id from #{st.o_id} to #{nv}"
if prod_mode
st.update_columns(o_id: nv)
puts "done..."
end
end
puts "Broken store object count after execution: #{Store.where("o_id LIKE '%.0'").count} or regex search (#{Store.where(%Q(o_id !~ '^[0-9]+$')).count})"
Rails.cache.clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment