Sha256: 0295a0a2ec4aad1f1db671c99ce8205e95dd7417ba29cbc1334f6ed9f225b568

Contents?: true

Size: 484 Bytes

Versions: 6

Compression:

Stored size: 484 Bytes

Contents

# frozen_string_literal: true

class FixAnsweredParagraphsAfterCopy < ActiveRecord::Migration[5.2]
  def change
    paragraphs_after_copy = Decidim::ResourceLink.where(from_type: "Decidim::EnhancedTextwork::Paragraph").pluck(:from_id)

    result = Decidim::EnhancedTextwork::Paragraph.where.not(state_published_at: nil).where(state: nil, id: paragraphs_after_copy)

    result.find_each do |paragraph|
      paragraph.state_published_at = nil
      paragraph.save!
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-enhanced_textwork-1.0.5 db/migrate/20210127115628_fix_answered_paragraphs_after_copy.rb
decidim-enhanced_textwork-1.0.4 db/migrate/20210127115628_fix_answered_paragraphs_after_copy.rb
decidim-enhanced_textwork-1.0.3 db/migrate/20210127115628_fix_answered_paragraphs_after_copy.rb
decidim-enhanced_textwork-1.0.2 db/migrate/20210127115628_fix_answered_paragraphs_after_copy.rb
decidim-enhanced_textwork-1.0.1 db/migrate/20210127115628_fix_answered_paragraphs_after_copy.rb
decidim-enhanced_textwork-1.0.0 db/migrate/20210127115628_fix_answered_paragraphs_after_copy.rb