From 4529da5c437325e0adbe0d1af07bd6145d5cc7e0 Mon Sep 17 00:00:00 2001 From: James Smith Date: Fri, 26 Jul 2024 11:55:41 +0100 Subject: [PATCH] fix taggable migration on MariaDB using solution from https://github.com/mbleigh/acts-as-taggable-on/issues/978 --- ...add_missing_unique_indices.acts_as_taggable_on_engine.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20210212143002_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20210212143002_add_missing_unique_indices.acts_as_taggable_on_engine.rb index 0d621815e..e17b2a52f 100644 --- a/db/migrate/20210212143002_add_missing_unique_indices.acts_as_taggable_on_engine.rb +++ b/db/migrate/20210212143002_add_missing_unique_indices.acts_as_taggable_on_engine.rb @@ -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