Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix migration #1072

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion db/migrate/1_acts_as_taggable_on_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def self.up
t.datetime :created_at
end

add_index ActsAsTaggableOn.taggings_table, :tag_id
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context],
name: 'taggings_taggable_context_idx'
end
Expand Down
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 @@ -4,7 +4,10 @@ class AddMissingUniqueIndices < ActiveRecord::Migration[6.0]
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 ActsAsTaggableOn.taggings_table, ActsAsTaggableOn.tags_table
remove_index ActsAsTaggableOn.taggings_table, :tag_id
end
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx'
add_index ActsAsTaggableOn.taggings_table,
%i[tag_id taggable_id taggable_type context tagger_id tagger_type],
Expand Down