diff options
author | Olivier Gonzalez <ogonzalez@gitlab.com> | 2018-09-04 18:52:03 -0400 |
---|---|---|
committer | Olivier Gonzalez <ogonzalez@gitlab.com> | 2018-09-04 18:52:03 -0400 |
commit | d5e9185618cc30227b2bd68f4322a3d7860152ee (patch) | |
tree | 678e985027317a670c5990d068ba752ca903a04d /config | |
parent | 91003c6ebb764c9cf3fe01a14d6213b26c09dcc8 (diff) | |
download | gitlab-ce-d5e9185618cc30227b2bd68f4322a3d7860152ee.tar.gz |
Make MySQL patch for binary indexes compatible with composite indexes
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/mysql_set_length_for_binary_indexes.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/config/initializers/mysql_set_length_for_binary_indexes.rb b/config/initializers/mysql_set_length_for_binary_indexes.rb index 1b16b39d517..81ed2fb83de 100644 --- a/config/initializers/mysql_set_length_for_binary_indexes.rb +++ b/config/initializers/mysql_set_length_for_binary_indexes.rb @@ -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 |