From 64b1b297e9972504ab12f6ce4652eb23473797f3 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Fri, 25 Jul 2014 17:10:25 -0300 Subject: [PATCH] Index published to improve blog posts fetch --- db/migrate/20140724180943_add_index_to_blog_posts_sort.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) create mode 100644 db/migrate/20140724180943_add_index_to_blog_posts_sort.rb diff --git a/db/migrate/20140724180943_add_index_to_blog_posts_sort.rb b/db/migrate/20140724180943_add_index_to_blog_posts_sort.rb new file mode 100644 index 0000000..31700b2 --- /dev/null +++ b/db/migrate/20140724180943_add_index_to_blog_posts_sort.rb @@ -0,0 +1,13 @@ +class AddIndexToBlogPostsSort < ActiveRecord::Migration + def self.up + %w[articles article_versions].each do |table| + add_index table, [:published_at, :id] + end + end + + def self.down + %w[articles article_versions].each do |table| + remove_index table, [:published_at, :id] + end + end +end -- libgit2 0.21.2