Commit c94b0a46 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Revert changes to mysql initializer

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 2bb221f0
# This patches ActiveRecord so indexes for binary and text columns created
# This patches ActiveRecord so indexes for binary columns created
# using the MySQL adapter apply a length of 20. Otherwise MySQL can't create an
# index on binary and text columns.
# index on binary columns.
module MysqlSetLengthForBinaryAndTextIndex
module MysqlSetLengthForBinaryIndex
def add_index(table_name, column_names, options = {})
Array(column_names).each do |column_name|
column = ActiveRecord::Base.connection.columns(table_name).find { |c| c.name == column_name }
if column&.type == :binary || column&.type == :text
if column&.type == :binary
options[:length] = 20
end
end
......@@ -17,5 +17,5 @@ module MysqlSetLengthForBinaryAndTextIndex
end
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:prepend, MysqlSetLengthForBinaryAndTextIndex)
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:prepend, MysqlSetLengthForBinaryIndex)
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment