forked from diaspora/diaspora
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added counter cache for photos on StatusMessage
- Loading branch information
1 parent
0929f15
commit 97b8045
Showing
6 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...3207_counter_cache_on_post_comments.rb.rb → ...1213207_counter_cache_on_post_comments.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
db/migrate/20111217042006_add_photo_counter_cache_to_post.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class AddPhotoCounterCacheToPost < ActiveRecord::Migration | ||
class Post < ActiveRecord::Base; end | ||
|
||
def self.up | ||
add_column :posts, :photos_count, :integer, :default => 0 | ||
execute <<SQL if Post.count > 0 | ||
UPDATE posts | ||
SET photos_count = (SELECT COUNT(*) FROM photos WHERE photos.status_message_guid = posts.guid) | ||
SQL | ||
end | ||
|
||
def self.down | ||
remove_column :posts, :photos_count | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters