aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorAlexander Negoda <alexander.negoda@gmail.com>2014-06-22 17:30:46 +0400
committerAlexander Negoda <alexander.negoda@gmail.com>2014-06-22 17:30:46 +0400
commitfb3b70a6dcb0a47ce1b76ff172d5584811c9fee2 (patch)
tree8eb07cdf815143ccf361e6f302d844296a4fc0a8 /db/migrate
parent52201b906cda54feebdba555ae92d260335a4d5f (diff)
downloadrefinerycms-blog-fb3b70a6dcb0a47ce1b76ff172d5584811c9fee2.tar.gz
refinerycms-blog-fb3b70a6dcb0a47ce1b76ff172d5584811c9fee2.tar.bz2
refinerycms-blog-fb3b70a6dcb0a47ce1b76ff172d5584811c9fee2.zip
added new migrations for acts-as-taggable-on engine
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb20
-rw-r--r--db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb15
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