Skip to content

Instantly share code, notes, and snippets.

@german
Last active August 11, 2016 16:30
Show Gist options
  • Save german/88665a10653cdd00182b53cc75f85f73 to your computer and use it in GitHub Desktop.
Save german/88665a10653cdd00182b53cc75f85f73 to your computer and use it in GitHub Desktop.
premium_yearly_sub = Subscription.all.detect{|s| s.subscription_type.name == 'yearly' && s.product.name == "aupeo-premium"}
saved = 0
sub_mappings = SubscriptionMapping.where(external_subscription_id: "com.aupeo.subscription.europe.yearly")
sub_mappings.each do |sm|
sm.subscription_id = premium_yearly_sub.id
if sm.save
puts "Subscription mapping's subscription_id was set for #{sm.country_code}"
saved +=1
else
puts "Error: #{sm.errors.inspect}"
end
end
puts "Changed #{saved} out of #{sub_mappings.count} subscription mappings"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment