Skip to content

Commit 95d468f

Browse files
committed
Add migration to make post authors follow new threads
1 parent 5de4162 commit 95d468f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class FollowOwnPosts < ActiveRecord::Migration[7.2]
2+
def change
3+
to_insert = Post.where.not(post_type_id: [PolicyDoc.post_type_id, HelpDoc.post_type_id])
4+
.where.not(user_id: nil)
5+
.pluck(:id, :user_id)
6+
.map { |post_id, user_id| { post_id: post_id, user_id: user_id } }
7+
8+
NewThreadFollower.insert_all(to_insert)
9+
end
10+
end

0 commit comments

Comments
 (0)