Sha256: f4a19ff49a79d82e432f92ba28f874894ddba86276f4ca21d63c6288f11ab079

Contents?: true

Size: 596 Bytes

Versions: 32

Compression:

Stored size: 596 Bytes

Contents

# frozen_string_literal: true

class SetPromotionsWithAnyPolicyToAllIfPossible < ActiveRecord::Migration[5.2]
  def up
    Spree::Promotion.where(match_policy: :any).includes(:promotion_rules).all.each do |promotion|
      if promotion.promotion_rules.length <= 1
        promotion.update!(match_policy: :all)
      else
        raise StandardError, <<~MSG
          You have promotions with a match policy of any and more than one rule. Please
          run `bundle exec rake solidus:split_promotions_with_any_match_policy`.
        MSG
      end
    end
  end

  def down
    # No-Op
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
solidus_core-4.1.3 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.0.4 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.4.6 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.0.3 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.1.2 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.4.5 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.1.1 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.0.2 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.4.4 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.3.4 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.2.9 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.2.8 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.3.3 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.4.3 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.0.1 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.1.0 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-4.0.0 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.4.2 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.2.7 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
solidus_core-3.3.2 db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb