diff options
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/20090815220058_migrate_tagging_tables.rb | 29 |
1 files changed, 29 insertions, 0 deletions
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 @@ | |||
| 1 | class MigrateTaggingTables < ActiveRecord::Migration | ||
| 2 | def self.up | ||
| 3 | add_column :tags, :taggings_count, :integer, :default => 0, :null => false | ||
| 4 | add_column :taggings, :user_id, :integer | ||
| 5 | |||
| 6 | add_index :tags, :name | ||
| 7 | add_index :tags, :taggings_count | ||
| 8 | |||
| 9 | Find objects for a tag | ||
| 10 | add_index :taggings, [:user_id, :tag_id, :taggable_type] | ||
| 11 | |||
| 12 | Find tags for an object | ||
| 13 | add_index :taggings, [:user_id, :taggable_id, :taggable_type] | ||
| 14 | end | ||
| 15 | |||
| 16 | def self.down | ||
| 17 | remove_column :tags, :taggings_count | ||
| 18 | remove_column :taggings, :user_id | ||
| 19 | |||
| 20 | remove_index :tags, :name | ||
| 21 | remove_index :tags, :taggings_count | ||
| 22 | |||
| 23 | # Find objects for a tag | ||
| 24 | remove_index :taggings, [:user_id, :tag_id, :taggable_type] | ||
| 25 | |||
| 26 | # Find tags for an object | ||
| 27 | remove_index :taggings, [:user_id, :taggable_id, :taggable_type] | ||
| 28 | end | ||
| 29 | end | ||
