Created
July 9, 2013 19:55
-
-
Save cpetersen/5960700 to your computer and use it in GitHub Desktop.
This code looks for wares that originate at central and have a ```promo_image```, these have likely been conflicted due to a bad migration. We then store them in JSON files on disk and delete them. Replication will then recreate them in an unconflicted state. This will not be run on central.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include FileUtils | |
directory = File.join(ENV['HOME'], "ware_backups") | |
FileUtils.mkdir_p(directory) | |
wares = [] | |
Ware.in_groups do |ware| | |
if(ware.promo_image.present? && ware.replication_permissions["central"] == "origin") | |
wares << ware | |
File.open(File.join(directory, "#{ware.id}.json"), "w") { |file| file.write ware.as_json } | |
end | |
end | |
# Code to load json files in case we want to get at them. | |
# Dir.glob(File.join(directory, "*")).each do |filename| | |
# puts filename | |
# obj = JSON.parse(File.read(filename)) | |
# end | |
wares.each { |ware| ware.destroy }; nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment