Commit 9c4f6041f607159ee74bbded0fd9809c1606f545

Authored by Rodrigo Souto
1 parent 131144ba

schema: add index for article and profile search order filters

(ActionItem3039)
db/migrate/20140312132212_add_indexes_for_article_search.rb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +class AddIndexesForArticleSearch < ActiveRecord::Migration
  2 + def self.up
  3 + add_index :articles, :created_at
  4 + add_index :articles, :hits
  5 + add_index :articles, :comments_count
  6 + end
  7 +
  8 + def self.down
  9 + remove_index :articles, :created_at
  10 + remove_index :articles, :hits
  11 + remove_index :articles, :comments_count
  12 + end
  13 +end
... ...
db/migrate/20140312134218_add_indexes_for_profile_search.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class AddIndexesForProfileSearch < ActiveRecord::Migration
  2 + def self.up
  3 + add_index :profiles, :created_at
  4 + end
  5 +
  6 + def self.down
  7 + remove_index :profiles, :created_at
  8 + end
  9 +end
... ...
db/schema.rb
... ... @@ -9,7 +9,7 @@
9 9 #
10 10 # It's strongly recommended to check this file into your version control system.
11 11  
12   -ActiveRecord::Schema.define(:version => 20140108132730) do
  12 +ActiveRecord::Schema.define(:version => 20140312151857) do
13 13  
14 14 create_table "abuse_reports", :force => true do |t|
15 15 t.integer "reporter_id"
... ... @@ -140,6 +140,9 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
140 140 t.integer "position"
141 141 end
142 142  
  143 + add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count"
  144 + add_index "articles", ["created_at"], :name => "index_articles_on_created_at"
  145 + add_index "articles", ["hits"], :name => "index_articles_on_hits"
143 146 add_index "articles", ["name"], :name => "index_articles_on_name"
144 147 add_index "articles", ["parent_id"], :name => "index_articles_on_parent_id"
145 148 add_index "articles", ["profile_id"], :name => "index_articles_on_profile_id"
... ... @@ -467,6 +470,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
467 470 t.string "redirection_after_login"
468 471 end
469 472  
  473 + add_index "profiles", ["created_at"], :name => "index_profiles_on_created_at"
470 474 add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id"
471 475 add_index "profiles", ["identifier"], :name => "index_profiles_on_identifier"
472 476 add_index "profiles", ["region_id"], :name => "index_profiles_on_region_id"
... ...