Sha256: 6d2666fae0155de00f6e67d65f719b379c6348a0c817a8402c4e2b16aed92f15

Contents?: true

Size: 884 Bytes

Versions: 13

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

class FixMeetingsRegistrationTerms < ActiveRecord::Migration[5.2]
  def up
    reset_column_information

    PaperTrail.request(enabled: false) do
      Decidim::Meetings::Meeting.find_each do |meeting|
        next if meeting.component.nil?
        # Only user-created meetings have this problem
        next if meeting.official?

        # Since user-created meetings have no way to override the `registration_terms` field
        # and it is supposed to use the component defaults,
        # we can safely override this.
        meeting.registration_terms = meeting.component.settings.default_registration_terms
        meeting.save!
      end
    end
    reset_column_information
  end

  def down; end

  def reset_column_information
    Decidim::Meetings::Meeting.reset_column_information
    Decidim::Component.reset_column_information
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.28.4 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.29.0 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.28.3 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.29.0.rc4 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.29.0.rc3 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.29.0.rc2 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.29.0.rc1 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.28.2 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.28.1 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.28.0 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.28.0.rc5 db/migrate/20201016065302_fix_meetings_registration_terms.rb
decidim-meetings-0.28.0.rc4 db/migrate/20201016065302_fix_meetings_registration_terms.rb