Skip to content

Instantly share code, notes, and snippets.

@pkqk
Created February 27, 2012 16:48
Show Gist options
  • Save pkqk/1925335 to your computer and use it in GitHub Desktop.
Save pkqk/1925335 to your computer and use it in GitHub Desktop.
if Rails::VERSION::MAJOR > 3 || Rails::VERSION::MINOR > 2
raise "Get rid of line #{__LINE__} in #{__FILE__}"
else
require 'schema_hotfix'
end
require 'active_record/connection_adapters/abstract_mysql_adapter'
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.class_eval do
def add_index_length(option_strings, column_names, options = {})
if options.is_a?(Hash) && length = options[:length]
case length
when Hash
column_names.each {|name| option_strings[name] += "(#{length[name]})" if length.has_key?(name) && length[name].present?}
when Fixnum
column_names.each {|name| option_strings[name] += "(#{length})"}
end
end
return option_strings
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment