From 61dc69cc5d8089ed9f96bc65dc64de6e075f70cf Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 24 Jun 2026 16:16:57 +0200 Subject: Upgrade acts-as-taggable-on to 3.5, add Rails 3.2 config fixes - Bump acts-as-taggable-on from 2.4.1 to 3.5.0 - Fake engine migrations for pre-existing schema - Set serve_static_assets in development - Fix request.fullpath in authenticated_system (request_uri removed in Rails 3.x) - Fix Paperclip path format to match existing file layout --- ...able_on_migration.acts_as_taggable_on_engine.rb | 31 ++++++++++++++++++++++ ...ng_unique_indices.acts_as_taggable_on_engine.rb | 20 ++++++++++++++ ...ter_cache_to_tags.acts_as_taggable_on_engine.rb | 15 +++++++++++ ...ng_taggable_index.acts_as_taggable_on_engine.rb | 10 +++++++ ...ion_for_tag_names.acts_as_taggable_on_engine.rb | 10 +++++++ 5 files changed, 86 insertions(+) create mode 100644 db/migrate/20260624035149_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb create mode 100644 db/migrate/20260624035150_add_missing_unique_indices.acts_as_taggable_on_engine.rb create mode 100644 db/migrate/20260624035151_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb create mode 100644 db/migrate/20260624035152_add_missing_taggable_index.acts_as_taggable_on_engine.rb create mode 100644 db/migrate/20260624035153_change_collation_for_tag_names.acts_as_taggable_on_engine.rb (limited to 'db') diff --git a/db/migrate/20260624035149_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/db/migrate/20260624035149_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..6bbd559 --- /dev/null +++ b/db/migrate/20260624035149_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb @@ -0,0 +1,31 @@ +# This migration comes from acts_as_taggable_on_engine (originally 1) +class ActsAsTaggableOnMigration < ActiveRecord::Migration + def self.up + create_table :tags do |t| + t.string :name + end + + create_table :taggings do |t| + t.references :tag + + # You should make sure that the column created is + # long enough to store the required class names. + t.references :taggable, polymorphic: true + t.references :tagger, polymorphic: true + + # Limit is created to prevent MySQL error on index + # length for MyISAM table type: http://bit.ly/vgW2Ql + t.string :context, limit: 128 + + t.datetime :created_at + end + + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def self.down + drop_table :taggings + drop_table :tags + end +end diff --git a/db/migrate/20260624035150_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20260624035150_add_missing_unique_indices.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..4ca676f --- /dev/null +++ b/db/migrate/20260624035150_add_missing_unique_indices.acts_as_taggable_on_engine.rb @@ -0,0 +1,20 @@ +# This migration comes from acts_as_taggable_on_engine (originally 2) +class AddMissingUniqueIndices < ActiveRecord::Migration + def self.up + add_index :tags, :name, unique: true + + remove_index :taggings, :tag_id + remove_index :taggings, [:taggable_id, :taggable_type, :context] + 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 :tags, :name + + remove_index :taggings, name: 'taggings_idx' + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end +end diff --git a/db/migrate/20260624035151_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20260624035151_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..8edb508 --- /dev/null +++ b/db/migrate/20260624035151_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb @@ -0,0 +1,15 @@ +# This migration comes from acts_as_taggable_on_engine (originally 3) +class AddTaggingsCounterCacheToTags < ActiveRecord::Migration + def self.up + add_column :tags, :taggings_count, :integer, default: 0 + + ActsAsTaggableOn::Tag.reset_column_information + ActsAsTaggableOn::Tag.find_each do |tag| + ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) + end + end + + def self.down + remove_column :tags, :taggings_count + end +end diff --git a/db/migrate/20260624035152_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/db/migrate/20260624035152_add_missing_taggable_index.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..71f2d7f --- /dev/null +++ b/db/migrate/20260624035152_add_missing_taggable_index.acts_as_taggable_on_engine.rb @@ -0,0 +1,10 @@ +# This migration comes from acts_as_taggable_on_engine (originally 4) +class AddMissingTaggableIndex < ActiveRecord::Migration + def self.up + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def self.down + remove_index :taggings, [:taggable_id, :taggable_type, :context] + end +end diff --git a/db/migrate/20260624035153_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20260624035153_change_collation_for_tag_names.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..bfb06bc --- /dev/null +++ b/db/migrate/20260624035153_change_collation_for_tag_names.acts_as_taggable_on_engine.rb @@ -0,0 +1,10 @@ +# This migration comes from acts_as_taggable_on_engine (originally 5) +# This migration is added to circumvent issue #623 and have special characters +# work properly +class ChangeCollationForTagNames < ActiveRecord::Migration + def up + if ActsAsTaggableOn::Utils.using_mysql? + execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") + end + end +end -- cgit v1.3