]> git.openstreetmap.org Git - rails.git/commitdiff
Add some indexes to diary entries to let recent entries be found
authorTom Hughes <tom@compton.nu>
Sun, 3 Jan 2010 11:56:41 +0000 (11:56 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 3 Jan 2010 11:56:41 +0000 (11:56 +0000)
efficiently for the various diary entry lists and feeds.

db/migrate/048_add_diary_creation_indexes.rb [new file with mode: 0644]

diff --git a/db/migrate/048_add_diary_creation_indexes.rb b/db/migrate/048_add_diary_creation_indexes.rb
new file mode 100644 (file)
index 0000000..d99831a
--- /dev/null
@@ -0,0 +1,13 @@
+class AddDiaryCreationIndexes < ActiveRecord::Migration
+  def self.up
+    add_index :diary_entries, [:created_at], :name => "diary_entry_created_at_index"
+    add_index :diary_entries, [:user_id, :created_at], :name => "diary_entry_user_id_created_at_index"
+    add_index :diary_entries, [:language_code, :created_at], :name => "diary_entry_language_code_created_at_index"
+  end
+
+  def self.down
+    remove_index :diary_entries, :name => "diary_entry_language_code_created_at_index"
+    remove_index :diary_entries, :name => "diary_entry_user_id_created_at_index"
+    remove_index :diary_entries, :name => "diary_entry_created_at_index"
+  end
+end