Sha256: 73179a70b7e7e362aedbd7dab393199de5162fbd2b12aae828d0766b2a1b6d02

Contents?: true

Size: 642 Bytes

Versions: 6

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

class FixUserGroupsIdsInParagraphsEndorsements < ActiveRecord::Migration[5.2]
  class ParagraphEndorsement < ApplicationRecord
    self.table_name = :decidim_enhanced_textwork_paragraph_endorsements
  end

  # rubocop:disable Rails/SkipsModelValidations
  def change
    Decidim::UserGroup.find_each do |group|
      old_id = group.extended_data["old_user_group_id"]
      next unless old_id

      Decidim::EnhancedTextwork::ParagraphEndorsement
        .where(decidim_user_group_id: old_id)
        .update_all(decidim_user_group_id: group.id)
    end
  end
  # rubocop:enable Rails/SkipsModelValidations
end

Version data entries

6 entries across 6 versions & 1 rubygems

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