diff options
| author | hukl <contact@smyck.org> | 2009-08-16 00:10:24 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-08-16 00:10:39 +0200 |
| commit | 8c202e546b43298b1ea4d2ad8cf378aaa4647a51 (patch) | |
| tree | 412157695c119f56d6faa7bdd2bc906e1f1c110b /db/migrate | |
| parent | 354ac3e285dc17be6304a85ec5a8385c05d3658c (diff) | |
migration to add missing columns and indexes for acts_as_taggable_redux as well as other related modifications
Diffstat (limited to 'db/migrate')
| -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 | ||
