Module: Lhm::SqlHelper

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

#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