def database_exists? begin retries ||= 0 ActiveRecord::Base.connection rescue => e STDERR.puts "#{e}" exit 1 else exit 0 end end database_exists?