Skip to content

Commit cf77af6

Browse files
committed
index posts.user_id,published
1 parent cf81e29 commit cf77af6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class IndexPostsUserIdAndPublished < ActiveRecord::Migration
2+
def up
3+
add_index :posts, [:user_id, :published]
4+
end
5+
6+
def down
7+
remove_index :posts, [:user_id, :published]
8+
end
9+
end

db/schema.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20110906065712) do
14+
ActiveRecord::Schema.define(:version => 20110906073224) do
1515

1616
create_table "posts", :force => true do |t|
1717
t.string "title"
@@ -24,6 +24,7 @@
2424

2525
add_index "posts", ["created_at"], :name => "index_posts_on_created_at"
2626
add_index "posts", ["published"], :name => "index_posts_on_published"
27+
add_index "posts", ["user_id", "published"], :name => "index_posts_on_user_id_and_published"
2728
add_index "posts", ["user_id"], :name => "index_posts_on_user_id"
2829

2930
create_table "users", :force => true do |t|

0 commit comments

Comments
 (0)