-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
6_add_missing_indexes_on_taggings.rb
24 lines (21 loc) · 1.41 KB
/
6_add_missing_indexes_on_taggings.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[6.0]
def change
add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id
add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table,
:taggable_id
add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table,
:taggable_type
add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table,
:tagger_id
add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context
unless index_exists? ActsAsTaggableOn.taggings_table, %i[tagger_id tagger_type]
add_index ActsAsTaggableOn.taggings_table, %i[tagger_id tagger_type]
end
unless index_exists? ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type tagger_id context],
name: 'taggings_idy'
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type tagger_id context],
name: 'taggings_idy'
end
end
end