File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change
1
+ class CreateCaseInsensitiveIndexesOnUser < ActiveRecord ::Migration
2
+
3
+ # User.with_username looks up on following fields almost
4
+ # constantly but with a UPPER(fieldname) = UPPER(val)
5
+ # which is nasty and slow, add upcase and downcase indexes
6
+ # to avoid the problem
7
+
8
+ def up
9
+ execute 'create index ix_users_github_lower on users (lower(github) varchar_pattern_ops)'
10
+ execute 'create index ix_users_github_upper on users (upper(github) varchar_pattern_ops)'
11
+ execute 'create index ix_users_linkedin_lower on users (lower(linkedin) varchar_pattern_ops)'
12
+ execute 'create index ix_users_linkedin_upper on users (upper(linkedin) varchar_pattern_ops)'
13
+ execute 'create index ix_users_twitter_lower on users (lower(twitter) varchar_pattern_ops)'
14
+ execute 'create index ix_users_twitter_upper on users (upper(twitter) varchar_pattern_ops)'
15
+ execute 'create index ix_users_username_lower on users (lower(username) varchar_pattern_ops)'
16
+ execute 'create index ix_users_username_upper on users (upper(username) varchar_pattern_ops)'
17
+ end
18
+
19
+ def down
20
+ execute 'drop index if exists ix_users_github_lower'
21
+ execute 'drop index if exists ix_users_github_upper'
22
+ execute 'drop index if exists ix_users_linkedin_lower'
23
+ execute 'drop index if exists ix_users_linkedin_upper'
24
+ execute 'drop index if exists ix_users_twitter_lower'
25
+ execute 'drop index if exists ix_users_twitter_upper'
26
+ execute 'drop index if exists ix_users_username_lower'
27
+ execute 'drop index if exists ix_users_username_upper'
28
+ end
29
+ end
Original file line number Diff line number Diff line change 11
11
#
12
12
# It's strongly recommended to check this file into your version control system.
13
13
14
- ActiveRecord ::Schema . define ( :version => 20140701170008 ) do
14
+ ActiveRecord ::Schema . define ( :version => 20140703223632 ) do
15
15
16
16
create_table "alias_tags" , :id => false , :force => true do |t |
17
17
t . integer "tag_id"
You can’t perform that action at this time.
0 commit comments