Skip to content

Instantly share code, notes, and snippets.

@SeanSith
Created June 30, 2020 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanSith/a91530d15eb7749295b2c052ba9ae54c to your computer and use it in GitHub Desktop.
Save SeanSith/a91530d15eb7749295b2c052ba9ae54c to your computer and use it in GitHub Desktop.
Migrate from Sequel Pro to Sequel Ace
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'plist'
end
preferences_file_source = "#{ENV['HOME']}/Library/Preferences/com.sequelpro.SequelPro.plist"
preferences_file_destination = "#{ENV['HOME']}/Library/Containers/com.sequel-ace.sequel-ace/Data/Library/Preferences/com.sequel-ace.sequel-ace.plist"
favorites_file_source = "#{ENV['HOME']}/Library/Application\ Support/Sequel\ Pro/Data/Favorites.plist"
favorites_file_destination = "#{ENV['HOME']}/Library/Containers/com.sequel-ace.sequel-ace/Data/Library/Application\ Support/Sequel\ Ace/Data/Favorites.plist"
if File.exist?(preferences_file_destination)
print "I see that you have already opened Sequel Ace once. Do you wish to copy preferences from Sequel Pro? [y|n] "
exit unless gets.chomp == 'y'
FileUtils.cp preferences_file_source, preferences_file_destination
else
puts "You have not opened Sequel Ace. I would recommend you do this at least once to initialize all of the directories needed."
exit
end
if File.exist?(favorites_file_destination)
puts "Please note that this migration file will not merge your saved connections if you've already started using Sequel Ace."
puts ""
print "Do you wish to copy your saved connections from Sequel Pro into Sequel Ace? [y|n] "
exit unless gets.chomp == 'y'
end
FileUtils.cp favorites_file_source, favorites_file_destination
result = Plist.parse_xml(favorites_file_destination)
result['Favorites Root']['Children'].each do |favorite|
favorite_identifier = "#{favorite['name']} (#{favorite['id']})"
account_name = `security find-generic-password -l "Sequel Pro : #{favorite_identifier}" 2>/dev/null| grep "acct"`.split('"')[3]
password = `security find-generic-password -l "Sequel Pro : #{favorite_identifier}" -w 2>/dev/null`
next if password.empty?
password.chomp!
puts "Migrating entry for \"Sequel Pro : #{favorite_identifier}\"..."
puts account_name + ' : ' + password
`security add-generic-password -a #{ENV['USER']} -a #{account_name} -s "Sequel Ace : #{favorite_identifier}" -T "/Applications/Sequel Ace.app" -w #{password}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment