Sha256: ad0f247b56978060c7f878199b9dde8bf7e923b01cc8cf51a2dceaf6b8e86b9a
Contents?: true
Size: 643 Bytes
Versions: 38
Compression:
Stored size: 643 Bytes
Contents
# frozen_string_literal: true class UpdateRootCommentableForComments < ActiveRecord::Migration[5.0] def up Decidim::Comments::Comment.where(depth: 0).update_all( "decidim_root_commentable_id = decidim_commentable_id, decidim_root_commentable_type = decidim_commentable_type" ) Decidim::Comments::Comment.where("depth > 0").find_each do |comment| comment.root_commentable = root_commentable(comment) comment.save(validate: false) end end def down; end private def root_commentable(comment) return comment.commentable if comment.depth.zero? root_commentable comment.commentable end end
Version data entries
38 entries across 38 versions & 2 rubygems