diff options
Diffstat (limited to 'db/migrate')
5 files changed, 86 insertions, 0 deletions
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 @@ | |||
| 1 | # This migration comes from acts_as_taggable_on_engine (originally 1) | ||
| 2 | class ActsAsTaggableOnMigration < ActiveRecord::Migration | ||
| 3 | def self.up | ||
| 4 | create_table :tags do |t| | ||
| 5 | t.string :name | ||
| 6 | end | ||
| 7 | |||
| 8 | create_table :taggings do |t| | ||
| 9 | t.references :tag | ||
| 10 | |||
| 11 | # You should make sure that the column created is | ||
| 12 | # long enough to store the required class names. | ||
| 13 | t.references :taggable, polymorphic: true | ||
| 14 | t.references :tagger, polymorphic: true | ||
| 15 | |||
| 16 | # Limit is created to prevent MySQL error on index | ||
| 17 | # length for MyISAM table type: http://bit.ly/vgW2Ql | ||
| 18 | t.string :context, limit: 128 | ||
| 19 | |||
| 20 | t.datetime :created_at | ||
| 21 | end | ||
| 22 | |||
| 23 | add_index :taggings, :tag_id | ||
| 24 | add_index :taggings, [:taggable_id, :taggable_type, :context] | ||
| 25 | end | ||
| 26 | |||
| 27 | def self.down | ||
| 28 | drop_table :taggings | ||
| 29 | drop_table :tags | ||
| 30 | end | ||
| 31 | 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 @@ | |||
| 1 | # This migration comes from acts_as_taggable_on_engine (originally 2) | ||
| 2 | class AddMissingUniqueIndices < ActiveRecord::Migration | ||
| 3 | def self.up | ||
| 4 | add_index :tags, :name, unique: true | ||
| 5 | |||
| 6 | remove_index :taggings, :tag_id | ||
| 7 | remove_index :taggings, [:taggable_id, :taggable_type, :context] | ||
| 8 | add_index :taggings, | ||
| 9 | [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], | ||
| 10 | unique: true, name: 'taggings_idx' | ||
| 11 | end | ||
| 12 | |||
| 13 | def self.down | ||
| 14 | remove_index :tags, :name | ||
| 15 | |||
| 16 | remove_index :taggings, name: 'taggings_idx' | ||
| 17 | add_index :taggings, :tag_id | ||
| 18 | add_index :taggings, [:taggable_id, :taggable_type, :context] | ||
| 19 | end | ||
| 20 | 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 @@ | |||
| 1 | # This migration comes from acts_as_taggable_on_engine (originally 3) | ||
| 2 | class AddTaggingsCounterCacheToTags < ActiveRecord::Migration | ||
| 3 | def self.up | ||
| 4 | add_column :tags, :taggings_count, :integer, default: 0 | ||
| 5 | |||
| 6 | ActsAsTaggableOn::Tag.reset_column_information | ||
| 7 | ActsAsTaggableOn::Tag.find_each do |tag| | ||
| 8 | ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) | ||
| 9 | end | ||
| 10 | end | ||
| 11 | |||
| 12 | def self.down | ||
| 13 | remove_column :tags, :taggings_count | ||
| 14 | end | ||
| 15 | 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 @@ | |||
| 1 | # This migration comes from acts_as_taggable_on_engine (originally 4) | ||
| 2 | class AddMissingTaggableIndex < ActiveRecord::Migration | ||
| 3 | def self.up | ||
| 4 | add_index :taggings, [:taggable_id, :taggable_type, :context] | ||
| 5 | end | ||
| 6 | |||
| 7 | def self.down | ||
| 8 | remove_index :taggings, [:taggable_id, :taggable_type, :context] | ||
| 9 | end | ||
| 10 | 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 @@ | |||
| 1 | # This migration comes from acts_as_taggable_on_engine (originally 5) | ||
| 2 | # This migration is added to circumvent issue #623 and have special characters | ||
| 3 | # work properly | ||
| 4 | class ChangeCollationForTagNames < ActiveRecord::Migration | ||
| 5 | def up | ||
| 6 | if ActsAsTaggableOn::Utils.using_mysql? | ||
| 7 | execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") | ||
| 8 | end | ||
| 9 | end | ||
| 10 | end | ||
