From b3a5a2acbf904379928adb83e7789384c859c3f8 Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 1 Sep 2009 12:04:58 +0200 Subject: added migration to add indices on several heavy duty columns. totally unrelated but huge performance win ;) --- db/migrate/20090901095657_add_indices.rb | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 db/migrate/20090901095657_add_indices.rb diff --git a/db/migrate/20090901095657_add_indices.rb b/db/migrate/20090901095657_add_indices.rb new file mode 100644 index 0000000..dd31046 --- /dev/null +++ b/db/migrate/20090901095657_add_indices.rb @@ -0,0 +1,53 @@ +class AddIndices < ActiveRecord::Migration + def self.up + change_table :pages do |t| + t.index :id + t.index :node_id + t.index :user_id + t.index :revision + end + + change_table :nodes do |t| + t.index :id + t.index :slug + t.index :unique_name + t.index :lft + t.index :rgt + t.index :parent_id + t.index :head_id + t.index :draft_id + t.index :locking_user_id + end + + change_table :page_translations do |t| + t.index :page_id + t.index :locale + end + end + + def self.down + change_table :pages do |t| + t.remove_index :id + t.remove_index :node_id + t.remove_index :user_id + t.remove_index :revision + end + + change_table :nodes do |t| + t.remove_index :id + t.remove_index :slug + t.remove_index :unique_name + t.remove_index :lft + t.remove_index :rgt + t.remove_index :parent_id + t.remove_index :head_id + t.remove_index :draft_id + t.remove_index :locking_user_id + end + + change_table :page_translations do |t| + t.remove_index :page_id + t.remove_index :locale + end + end +end -- cgit v1.3