Skip to content

Commit

Permalink
Removing foreign_key when removing index
Browse files Browse the repository at this point in the history
Error explained in issue 978 (mbleigh#978)
  • Loading branch information
ndrix authored Jan 20, 2020
1 parent 6055f96 commit 4945323
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion db/migrate/2_add_missing_unique_indices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ class AddMissingUniqueIndices < ActiveRecord::Migration; end
def self.up
add_index ActsAsTaggableOn.tags_table, :name, unique: true

remove_index ActsAsTaggableOn.taggings_table, :tag_id if index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
if index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
remove_foreign_key :taggings, :tags
remove_index ActsAsTaggableOn.taggings_table, :tag_id
end
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx'
add_index ActsAsTaggableOn.taggings_table,
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
Expand Down

0 comments on commit 4945323

Please sign in to comment.