Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-07-25 17:45:13 +0300
committerAlexis Reigel <mail@koffeinfrei.org>2017-07-27 16:46:03 +0300
commit07dbd5649ad18e4473c10ef8a1a70ea863b88cc4 (patch)
treec5e0d14dadb6646c2336d48a624e388a2b99ad5d /config
parentecbc11a839f7a48402e912f1176735770c091829 (diff)
use Module#prepend instead of alias_method_chain
Diffstat (limited to 'config')
-rw-r--r--config/initializers/mysql_set_length_for_binary_indexes.rb28
1 files changed, 12 insertions, 16 deletions
diff --git a/config/initializers/mysql_set_length_for_binary_indexes.rb b/config/initializers/mysql_set_length_for_binary_indexes.rb
index b5c6e39f6a8..de0bc5322aa 100644
--- a/config/initializers/mysql_set_length_for_binary_indexes.rb
+++ b/config/initializers/mysql_set_length_for_binary_indexes.rb
@@ -2,24 +2,20 @@
# MySQL adapter apply a length of 20. Otherwise MySQL can't create an index on
# binary columns.
-if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
- module ActiveRecord
- module ConnectionAdapters
- class Mysql2Adapter < AbstractMysqlAdapter
- alias_method :__gitlab_add_index2, :add_index
-
- 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 }
+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
- options[:length] = 20
- end
- end
-
- __gitlab_add_index2(table_name, column_names, options)
- end
+ if column&.type == :binary
+ options[:length] = 20
end
end
+
+ super(table_name, column_names, options)
end
end
+
+if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
+ ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:prepend, MysqlSetLengthForBinaryIndex)
+end