diff options
Diffstat (limited to 'db/migrate/20210323165714_update_promotion_rule_names.rb')
-rw-r--r-- | db/migrate/20210323165714_update_promotion_rule_names.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrate/20210323165714_update_promotion_rule_names.rb b/db/migrate/20210323165714_update_promotion_rule_names.rb new file mode 100644 index 0000000..f6ee6c2 --- /dev/null +++ b/db/migrate/20210323165714_update_promotion_rule_names.rb @@ -0,0 +1,22 @@ +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 |