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 --- app/models/page.rb | 2 +- app/views/nodes/edit.html.erb | 2 +- .../20090815220058_migrate_tagging_tables.rb | 29 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20090815220058_migrate_tagging_tables.rb diff --git a/app/models/page.rb b/app/models/page.rb index 30f5ec2..b6d6489 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -121,7 +121,7 @@ class Page < ActiveRecord::Base self.reload # Clone untranslated attributes - self.tag_list = page.tag_list.join(", ") + self.tag_list = page.tag_list self.template_name = page.template_name self.published_at = page.published_at diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index f37a24b..5973a6c 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb @@ -23,7 +23,7 @@ <% fields_for @draft do |d| %> Tags - comma seperated - <%= text_field_tag :tag_list, @draft.tag_list.join(", ") %> + <%= text_field_tag :tag_list, @draft.tag_list %> Publish at 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