6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/rare_map/schema_reader.rb', line 6
def read_schema(db_profile)
conn = db_profile.connection.map { |k, v| v.kind_of?(Integer) ? "'#{k}'=>#{v}" : "'#{k}'=>'#{v}'" }.join(', ')
schema = if RUBY_PLATFORM == 'java'
%x[jruby -e "require 'active_record'; require 'activerecord-jdbc-adapter'; ActiveRecord::Base.establish_connection(#{conn}); ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection);" 2>&1]
else
%x[ruby -e "require 'active_record'; ActiveRecord::Base.establish_connection(#{conn}); ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection);" 2>&1]
end
detect_errors schema
schema
end
|