Sha256: a2acbfe11cb12d8750fa9e7b75e46ce6e6cdf4a3991446d42105db70175e0bc4

Contents?: true

Size: 505 Bytes

Versions: 15

Compression:

Stored size: 505 Bytes

Contents

# frozen_string_literal: true

class FixUserGroupsIdsInProposalsEndorsements < ActiveRecord::Migration[5.2]
  # 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::Proposals::ProposalEndorsement
        .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

15 entries across 15 versions & 1 rubygems

Version Path
decidim-proposals-0.21.0 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.20.1 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.20.0 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.19.1 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.18.1 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.19.0 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.17.2 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.18.0 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.17.1 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.16.1 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.17.0 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.16.0 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.15.2 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.15.1 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb
decidim-proposals-0.15.0 db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb