-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29c20c0
commit d8028b0
Showing
7 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
db/migrate/20250204102932_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from acts_as_taggable_on_engine (originally 1) | ||
class ActsAsTaggableOnMigration < ActiveRecord::Migration[6.0] | ||
def self.up | ||
create_table ActsAsTaggableOn.tags_table do |t| | ||
t.string :name | ||
t.timestamps | ||
end | ||
|
||
create_table ActsAsTaggableOn.taggings_table do |t| | ||
t.references :tag, foreign_key: { to_table: ActsAsTaggableOn.tags_table } | ||
|
||
# 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 ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context], | ||
name: 'taggings_taggable_context_idx' | ||
end | ||
|
||
def self.down | ||
drop_table ActsAsTaggableOn.taggings_table | ||
drop_table ActsAsTaggableOn.tags_table | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
db/migrate/20250204102933_add_missing_unique_indices.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from acts_as_taggable_on_engine (originally 2) | ||
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) | ||
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], | ||
unique: true, name: 'taggings_idx' | ||
end | ||
|
||
def self.down | ||
remove_index ActsAsTaggableOn.tags_table, :name | ||
|
||
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_idx' | ||
|
||
add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists?(ActsAsTaggableOn.taggings_table, :tag_id) | ||
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context], | ||
name: 'taggings_taggable_context_idx' | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
db/migrate/20250204102934_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from acts_as_taggable_on_engine (originally 3) | ||
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[6.0] | ||
def self.up | ||
add_column ActsAsTaggableOn.tags_table, :taggings_count, :integer, default: 0 | ||
|
||
ActsAsTaggableOn::Tag.reset_column_information | ||
ActsAsTaggableOn::Tag.find_each do |tag| | ||
ActsAsTaggableOn::Tag.reset_counters(tag.id, ActsAsTaggableOn.taggings_table) | ||
end | ||
end | ||
|
||
def self.down | ||
remove_column ActsAsTaggableOn.tags_table, :taggings_count | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
db/migrate/20250204102935_add_missing_taggable_index.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from acts_as_taggable_on_engine (originally 4) | ||
class AddMissingTaggableIndex < ActiveRecord::Migration[6.0] | ||
def self.up | ||
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type context], | ||
name: 'taggings_taggable_context_idx' | ||
end | ||
|
||
def self.down | ||
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx' | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
db/migrate/20250204102936_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
# 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[6.0] | ||
def up | ||
if ActsAsTaggableOn::Utils.using_mysql? | ||
execute("ALTER TABLE #{ActsAsTaggableOn.tags_table} MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") | ||
end | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
db/migrate/20250204102937_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
# This migration comes from acts_as_taggable_on_engine (originally 6) | ||
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[6.0] | ||
def change | ||
add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id | ||
add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table, | ||
:taggable_id | ||
add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table, | ||
:taggable_type | ||
add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table, | ||
:tagger_id | ||
add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context | ||
|
||
unless index_exists? ActsAsTaggableOn.taggings_table, %i[tagger_id tagger_type] | ||
add_index ActsAsTaggableOn.taggings_table, %i[tagger_id tagger_type] | ||
end | ||
|
||
unless index_exists? ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type tagger_id context], | ||
name: 'taggings_idy' | ||
add_index ActsAsTaggableOn.taggings_table, %i[taggable_id taggable_type tagger_id context], | ||
name: 'taggings_idy' | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.