lib/lhm/sql_helper.rb in lhm-1.0.0.rc6 vs lib/lhm/sql_helper.rb in lhm-1.0.0.rc7
- old
+ new
@@ -3,18 +3,22 @@
module Lhm
module SqlHelper
extend self
+ def annotation
+ "/* large hadron migration */"
+ end
+
def idx_name(table_name, cols)
column_names = column_definition(cols).map(&:first)
"index_#{ table_name }_on_#{ column_names.join("_and_") }"
end
def idx_spec(cols)
column_definition(cols).map do |name, length|
- "`#{name}`#{length}"
+ "`#{ name }`#{ length }"
end.join(', ')
end
def table?(table_name)
connection.table_exists?(table_name)
@@ -37,10 +41,10 @@
end
private
def tagged(statement)
- statement + " -- lhm"
+ "#{ statement } #{ SqlHelper.annotation }"
end
def column_definition(cols)
Array(cols).map do |column|
column.to_s.match(/`?([^\(]+)`?(\([^\)]+\))?/).captures