Sha256: 5542fe96419a2ad837978cc0784d08fa02900dfc74aca42f43a8f0031943dd0c

Contents?: true

Size: 739 Bytes

Versions: 7

Compression:

Stored size: 739 Bytes

Contents

class UpdatePromotionRuleNames < ActiveRecord::Migration[5.2]
  TYPE_RENAMES = {
    'SolidusSubscriptions::SubscriptionPromotionRule' => 'SolidusSubscriptions::Promotion::Rules::SubscriptionCreationOrder',
    'SolidusSubscriptions::SubscriptionOrderPromotionRule' => 'SolidusSubscriptions::Promotion::Rules::SubscriptionInstallmentOrder',
  }.freeze

  def change
    reversible do |dir|
      dir.up do
        TYPE_RENAMES.each do |old_type, new_type|
          Spree::PromotionRule.where(type: old_type).update(type: new_type)
        end
      end

      dir.down do
        TYPE_RENAMES.each do |old_type, new_type|
          Spree::PromotionRule.where(type: new_type).update(type: old_type)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solidus_subscriptions-2.0.2 db/migrate/20210323165714_update_promotion_rule_names.rb
solidus_subscriptions-2.0.1 db/migrate/20210323165714_update_promotion_rule_names.rb
solidus_subscriptions-2.0.0 db/migrate/20210323165714_update_promotion_rule_names.rb
solidus_subscriptions-1.1.0 db/migrate/20210323165714_update_promotion_rule_names.rb
solidus_subscriptions-1.0.1 db/migrate/20210323165714_update_promotion_rule_names.rb
solidus_subscriptions-1.0.0 db/migrate/20210323165714_update_promotion_rule_names.rb
solidus_subscriptions-1.0.0.rc1 db/migrate/20210323165714_update_promotion_rule_names.rb