mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Initial release of Discourse
This commit is contained in:
19
db/migrate/20120703210004_add_bookmark_count_to_posts.rb
Normal file
19
db/migrate/20120703210004_add_bookmark_count_to_posts.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class AddBookmarkCountToPosts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :posts, :bookmark_count, :integer, default: 0, null: false
|
||||
add_column :forum_threads, :bookmark_count, :integer, default: 0, null: false
|
||||
add_column :forum_threads, :star_count, :integer, default: 0, null: false
|
||||
|
||||
execute "UPDATE posts SET bookmark_count = (SELECT COUNT(*)
|
||||
FROM bookmarks
|
||||
WHERE post_number = posts.post_number AND forum_thread_id = posts.forum_thread_id)"
|
||||
|
||||
execute "UPDATE forum_threads SET bookmark_count = (SELECT COUNT(*)
|
||||
FROM bookmarks
|
||||
WHERE forum_thread_id = forum_threads.id)"
|
||||
|
||||
execute "UPDATE forum_threads SET star_count = (SELECT COUNT(*)
|
||||
FROM forum_thread_users
|
||||
WHERE forum_thread_id = forum_threads.id AND starred = true)"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user