Module: Lhm::SqlHelper

Extended by:
SqlHelper
Included in:
Chunker, Entangler, Invoker, LockedSwitcher, Migrator, SqlHelper, Table::Parser
Defined in:
lib/lhm/sql_helper.rb

Instance Method Summary collapse

Instance Method Details

#annotationObject


8
9
10
# File 'lib/lhm/sql_helper.rb', line 8

def annotation
  '/* large hadron migration */'
end

#idx_name(table_name, cols) ⇒ Object


12
13
14
15
# File 'lib/lhm/sql_helper.rb', line 12

def idx_name(table_name, cols)
  column_names = column_definition(cols).map(&:first)
  "index_#{ table_name }_on_#{ column_names.join('_and_') }"
end

#idx_spec(cols) ⇒ Object


17
18
19
20
21
# File 'lib/lhm/sql_helper.rb', line 17

def idx_spec(cols)
  column_definition(cols).map do |name, length|
    "`#{ name }`#{ length }"
  end.join(', ')
end

#tagged(statement) ⇒ Object


29
30
31
# File 'lib/lhm/sql_helper.rb', line 29

def tagged(statement)
  "#{ statement } #{ SqlHelper.annotation }"
end

#version_stringObject


23
24
25
26
27
# File 'lib/lhm/sql_helper.rb', line 23

def version_string
  row = connection.select_one("show variables like 'version'")
  value = struct_key(row, 'Value')
  row[value]
end