Skip to content

Commit

Permalink
Manual scripts for user migration (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbianco-stripe authored Aug 16, 2022
1 parent eaf31a7 commit 2b436f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/batch-modification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
StripeForce::User.all.each do |user|
if user.connector_settings['filters']['Order'].nil?
puts "Updating order filter"
user.connector_settings['filters']['Order'] = "Status = 'Activated'"
user.save(columns: [:connector_settings])
else
puts "Skipping order filter:\t#{user.id}"
end
end
23 changes: 23 additions & 0 deletions scripts/copy-user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# DO NOT RUN DIRECTLY
# hacky script to help migrate users between databases, leaving around in case we need it in the future

user = StripeForce::User.find(salesforce_instance_url: "https://stripe.my.salesforce.com")
Marshal.dump(user.to_hash)

# separate machine
user_hash = Marshal.load(load_str)
user_hash.delete(:id)
user_hash[:field_defaults] = JSON.parse(user_hash[:field_defaults])
user_hash[:field_mappings] = JSON.parse(user_hash[:field_mappings])
user_hash[:feature_flags] = JSON.parse(user_hash[:feature_flags])

salesforce_refresh_token = user_hash.delete(:salesforce_refresh_token)
salesforce_token = user_hash.delete(:salesforce_token)
connector_settings = JSON.parse(user_hash.delete(:connector_settings))
user_hash.delete(:stripe_refresh_token)

user = StripeForce::User.new(user_hash)
user.salesforce_token = salesforce_token
user.salesforce_refresh_token = salesforce_refresh_token
user.connector_settings = connector_settings
user.save

0 comments on commit 2b436f5

Please sign in to comment.