Bump acts-as-taggable-on to 6.0.0
Rails 5.1 introduced certain changes in the way a record is touched when the counter cache option is enabled in a belongs to association. We need to upgrade acts-as-taggable-on so it keeps changing the `updated_at` attribute when a new tag is added to a record. Note we now need to reload the records in some cases to get the `context_tag_list` method to return what we expect. Methods like `context_tags` however work properly with no need to reload the record.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 2)
|
||||
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
||||
class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
|
||||
else
|
||||
class AddMissingUniqueIndices < ActiveRecord::Migration; end
|
||||
end
|
||||
AddMissingUniqueIndices.class_eval do
|
||||
def self.up
|
||||
add_index :taggings,
|
||||
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
|
||||
unique: true, name: "taggings_idx"
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :taggings, name: "taggings_idx"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 6)
|
||||
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
||||
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
|
||||
else
|
||||
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
|
||||
end
|
||||
AddMissingIndexesOnTaggings.class_eval do
|
||||
def change
|
||||
add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
|
||||
add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
|
||||
add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
|
||||
add_index :taggings, :context unless index_exists? :taggings, :context
|
||||
|
||||
unless index_exists? :taggings, [:tagger_id, :tagger_type]
|
||||
add_index :taggings, [:tagger_id, :tagger_type]
|
||||
end
|
||||
|
||||
unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: "taggings_idy"
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: "taggings_idy"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1390,8 +1390,15 @@ ActiveRecord::Schema.define(version: 20191108173350) do
|
||||
t.integer "tagger_id"
|
||||
t.string "context", limit: 128
|
||||
t.datetime "created_at"
|
||||
t.index ["context"], name: "index_taggings_on_context"
|
||||
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
|
||||
t.index ["tag_id"], name: "index_taggings_on_tag_id"
|
||||
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
||||
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
|
||||
t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
|
||||
t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
|
||||
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
|
||||
t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
|
||||
end
|
||||
|
||||
create_table "tags", id: :serial, force: :cascade do |t|
|
||||
|
||||
Reference in New Issue
Block a user