Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ce4e0837
Commit
ce4e0837
authored
Jul 25, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql hack: set length for binary indexes
parent
eda00156
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
config/initializers/mysql_set_length_for_binary_indexes.rb
config/initializers/mysql_set_length_for_binary_indexes.rb
+25
-0
No files found.
config/initializers/mysql_set_length_for_binary_indexes.rb
0 → 100644
View file @
ce4e0837
# 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 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
}
if
column
&
.
type
==
:binary
options
[
:length
]
=
20
end
end
__gitlab_add_index2
(
table_name
,
column_names
,
options
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment