diff options
author | lucalanda <lucalanda@hotmail.it> | 2021-03-26 10:30:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 10:30:12 +0100 |
commit | f96097ffabef7e6ff6138054543503d33a7a3043 (patch) | |
tree | b24c23240d9026edd2a4da0730d8e12b2db31b6b | |
parent | d2e2a338e7465d38a3148d168618b449cdbf1580 (diff) | |
parent | 9ffa0abb99aa91ea4ac8b3ddbfd30a6a149a947d (diff) |
Merge pull request #216 from solidusio-contrib/luca-landa/update-promotion-rule-names-on-db
Update promotion rule names on db
-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 |