diff options
author | Philip Arndt <p@arndt.io> | 2014-06-22 16:06:56 +0200 |
---|---|---|
committer | Philip Arndt <p@arndt.io> | 2014-06-22 16:06:56 +0200 |
commit | 10c8cc6b8e49eb9f91e959b95b839bd156999c8d (patch) | |
tree | 8eb07cdf815143ccf361e6f302d844296a4fc0a8 /db | |
parent | 52201b906cda54feebdba555ae92d260335a4d5f (diff) | |
parent | fb3b70a6dcb0a47ce1b76ff172d5584811c9fee2 (diff) | |
download | refinerycms-blog-10c8cc6b8e49eb9f91e959b95b839bd156999c8d.tar.gz refinerycms-blog-10c8cc6b8e49eb9f91e959b95b839bd156999c8d.tar.bz2 refinerycms-blog-10c8cc6b8e49eb9f91e959b95b839bd156999c8d.zip |
Merge pull request #380 from greendog/master
added new migrations for acts-as-taggable-on engine
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb | 20 | ||||
-rw-r--r-- | db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb | 15 |
2 files changed, 35 insertions, 0 deletions
diff --git a/db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..4ca676f --- /dev/null +++ b/db/migrate/20140622132537_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/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..8edb508 --- /dev/null +++ b/db/migrate/20140622132538_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 |