mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
12 lines
367 B
Ruby
12 lines
367 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddCommentsCountToEvents < ActiveRecord::Migration
|
|
def change
|
|
add_column :events, :comments_count, :integer, default: 0, null: false
|
|
|
|
Event.find_each do |event|
|
|
comments_count = event.comment_threads.count
|
|
event.update_attribute(:comments_count, comments_count) unless comments_count.zero?
|
|
end
|
|
end
|
|
end
|