Sha256: ee294f9480e1d61ef5e7510b123682c1d3109be1e468117bfa498cc3b6366386

Contents?: true

Size: 658 Bytes

Versions: 10

Compression:

Stored size: 658 Bytes

Contents

# frozen_string_literal: true

# This migration comes from spree (originally 20220317165036)
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

10 entries across 10 versions & 2 rubygems

Version Path
solidus_prototypes-1.6.0 spec/dummy/db/migrate/20231107091983_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_prototypes-1.5.1 spec/dummy/db/migrate/20231107091983_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_prototypes-1.5.0 spec/dummy/db/migrate/20231107091983_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_prototypes-1.4.0 spec/dummy/db/migrate/20231107091983_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_prototypes-1.3.0 spec/dummy/db/migrate/20230326093441_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_reports-1.2.0 spec/dummy/db/migrate/20230326095749_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_prototypes-1.2.0 spec/dummy/db/migrate/20221122203167_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_prototypes-1.1.1 spec/dummy/db/migrate/20221014070482_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_reports-1.1.0 spec/dummy/db/migrate/20221012211973_set_promotions_with_any_policy_to_all_if_possible.spree.rb
solidus_prototypes-1.1.0 spec/dummy/db/migrate/20221012201081_set_promotions_with_any_policy_to_all_if_possible.spree.rb