Skip to content

Instantly share code, notes, and snippets.

@jgn
Created January 20, 2016 15:33
Show Gist options
  • Save jgn/85633e6654a7fd6efc26 to your computer and use it in GitHub Desktop.
Save jgn/85633e6654a7fd6efc26 to your computer and use it in GitHub Desktop.
require 'active_record'
blacklist = {
icis_production: [ 'patient_versions', 'patients' ],
snowflake_production: [ 'persons' ]
}
blacklist.each_pair do |database, blacklisted_tables|
spec = {
adapter: :postgresql,
database: database,
username: ENV['GM_USERNAME'],
password: ENV['GM_PASSWORD']
}
ActiveRecord::Base.establish_connection(spec)
puts "Tables for #{database} without blacklisted tables:"
tables_wo_blacklist = ActiveRecord::Base.connection.tables - blacklisted_tables
puts " #{tables_wo_blacklist.sort.join(', ')}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment