Skip to content

Instantly share code, notes, and snippets.

@panbanda
Created December 5, 2020 11:23
Show Gist options
  • Save panbanda/d4013239239c57c8adb6e8f7325305ab to your computer and use it in GitHub Desktop.
Save panbanda/d4013239239c57c8adb6e8f7325305ab to your computer and use it in GitHub Desktop.
Migrating Stripe Subscriptions to Discourse Subscriptions
::DiscourseSubscriptions::Subscription.all.each do |sub|
stripe_sub = ::Stripe::Subscription.retrieve(sub[:external_id])
group_name = stripe_sub[:plan][:metadata][:group_name]
group = ::Group.find_by_name(group_name.downcase)
user = ::User.find(sub.customer.user_id)
group.add(user) if group
puts "#{group_name} #{group&.id} <- #{user.email}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment