lib/arcopy/copy.rb
# Let source db to generate schema and import it into
# target db
Let source db to generate schema and import it into
target db
Let source db to generate schema and import it into target db
def copy_schema
      io = StringIO.new
      ActiveRecord::SchemaDumper.dump(SourceDB.connection, io)
      io.rewind
      if @target_db['adapter'].include?('postgresql')
        f = []
        io.read.split("\n").each do |line|
          if line.include?('binary') && line.include?('limit')
            line = line.gsub(/,\s*\:limit\s*=>\s*\d*/, '')
          end
          f << line
        end
        eval(f.join("\n"))
      else
        eval(io)
      end
    end
def copy_schema io = StringIO . new ActiveRecord :: SchemaDumper . dump ( SourceDB . connection , io ) io . rewind if @target_db [ 'adapter' ] . include? ( 'postgresql' ) f = [ ] io . read . split ( "\n" ) . each do | line | if line . include? ( 'binary' ) && line . include? ( 'limit' ) line = line . gsub ( / , \s * \: limit \s *=> \s * \d * / , '' ) end f << line end eval ( f . join ( "\n" ) ) else eval ( io ) end end
Let source db to generate schema and import it into
target db
Let source db to generate schema and import it into target db
# IO # Call schema dumper on source db! # Rewind io # If target database is PGSQL # we have to remove all :limits for binary data # types (pgsql does not support them!) # Simply eval schema dump