From 8c202e546b43298b1ea4d2ad8cf378aaa4647a51 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 16 Aug 2009 00:10:24 +0200 Subject: migration to add missing columns and indexes for acts_as_taggable_redux as well as other related modifications --- .../20090815220058_migrate_tagging_tables.rb | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 db/migrate/20090815220058_migrate_tagging_tables.rb (limited to 'db') diff --git a/db/migrate/20090815220058_migrate_tagging_tables.rb b/db/migrate/20090815220058_migrate_tagging_tables.rb new file mode 100644 index 0000000..59e054f --- /dev/null +++ b/db/migrate/20090815220058_migrate_tagging_tables.rb @@ -0,0 +1,29 @@ +class MigrateTaggingTables < ActiveRecord::Migration + def self.up + add_column :tags, :taggings_count, :integer, :default => 0, :null => false + add_column :taggings, :user_id, :integer + + add_index :tags, :name + add_index :tags, :taggings_count + + Find objects for a tag + add_index :taggings, [:user_id, :tag_id, :taggable_type] + + Find tags for an object + add_index :taggings, [:user_id, :taggable_id, :taggable_type] + end + + def self.down + remove_column :tags, :taggings_count + remove_column :taggings, :user_id + + remove_index :tags, :name + remove_index :tags, :taggings_count + + # Find objects for a tag + remove_index :taggings, [:user_id, :tag_id, :taggable_type] + + # Find tags for an object + remove_index :taggings, [:user_id, :taggable_id, :taggable_type] + end +end -- cgit v1.3