lib/zdm.rb
# Recreate the indexes previously dropped, using 1 statement so the table
# is read through once.
Recreate the indexes previously dropped, using 1 statement so the table
is read through once.
Recreate the indexes previously dropped using 1 statement so the table is read through once .
def create_copy_indexes
        return if @indexes.empty?
        indexes = @indexes.map do |index_def|
          lengths = if index_def.lengths.is_a?(Hash)
            index_def.lengths
          elsif index_def.lengths.compact.any?
            Hash[index_def.columns.map.with_index { |col, idx| [col, index_def.lengths[idx]] }]
          end
          index_columns = index_def.columns.map.with_index do |col, idx|
            index_col_name = '`%s`' % col
            column_length = lengths && lengths[col]
            index_col_name << '(%s)' % column_length if column_length
            index_col_name
          end
          "ADD INDEX `#{index_def.name}` (#{index_columns.join(',')}) USING #{index_def.using}"
        end
        execute('ALTER TABLE `%s` %s' % [table.copy, indexes.join(', ')])
      end
def create_copy_indexes return if @indexes . empty? indexes = @indexes . map do | index_def | lengths = if index_def . lengths . is_a? ( Hash ) index_def . lengths elsif index_def . lengths . compact . any? Hash [ index_def . columns . map . with_index { | col , idx | [ col , index_def . lengths [ idx ] ] } ] end index_columns = index_def . columns . map . with_index do | col , idx | index_col_name = '`%s`' % col column_length = lengths && lengths [ col ] index_col_name << '(%s)' % column_length if column_length index_col_name end "ADD INDEX `#{index_def.name}` (#{index_columns.join(',')}) USING #{index_def.using}" end execute ( 'ALTER TABLE `%s` %s' % [ table . copy , indexes . join ( ', ' ) ] ) end
Recreate the indexes previously dropped, using 1 statement so the table
is read through once.
Recreate the indexes previously dropped using 1 statement so the table is read through once .