Commit 4a3a7497 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'fix_mysql_binary_index_patch' into 'master'

Make MySQL patch for binary indexes compatible with composite indexes

See merge request gitlab-org/gitlab-ce!21511
parents df1a9d67 d5e91856
......@@ -7,11 +7,12 @@
# the old Rails 4 schema layout is still used
module MysqlSetLengthForBinaryIndex
def add_index(table_name, column_names, options = {})
options[:length] ||= {}
Array(column_names).each do |column_name|
column = ActiveRecord::Base.connection.columns(table_name).find { |c| c.name == column_name }
if column&.type == :binary
options[:length] = 20
options[:length][column_name] = 20
end
end
......@@ -27,11 +28,12 @@ if Gitlab.rails5?
module MysqlSetLengthForBinaryIndexAndIgnorePostgresOptionsForSchema
# This method is used in Rails 5 schema loading as t.index
def index(column_names, options = {})
options[:length] ||= {}
Array(column_names).each do |column_name|
column = columns.find { |c| c.name == column_name }
if column&.type == :binary
options[:length] = 20
options[:length][column_name] = 20
end
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