Skip to content

Commit

Permalink
fix taggable migration on MariaDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Jul 26, 2024
1 parent 2e2cf3a commit 4529da5
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ 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],
unique: true, name: "taggings_idx"
add_foreign_key ActsAsTaggableOn.taggings_table, ActsAsTaggableOn.tags_table, column: 'tag_id'
end

def self.down
Expand Down

0 comments on commit 4529da5

Please sign in to comment.