Class: SolidusFriendlyPromotions::MigrateAdjustments
- Inherits:
-
Object
- Object
- SolidusFriendlyPromotions::MigrateAdjustments
- Defined in:
- lib/solidus_friendly_promotions/migrate_adjustments.rb
Class Method Summary collapse
Class Method Details
.down ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/solidus_friendly_promotions/migrate_adjustments.rb', line 29 def down sql = if ActiveRecord::Base.connection_db_config.adapter == "mysql2" <<~SQL UPDATE spree_adjustments INNER JOIN friendly_benefits INNER JOIN spree_promotion_actions ON spree_adjustments.source_id = friendly_benefits.id and spree_adjustments.source_type = 'SolidusFriendlyPromotions::Benefit' SET source_id = spree_promotion_actions.id, source_type = 'Spree::PromotionAction' WHERE friendly_benefits.original_promotion_action_id = spree_promotion_actions.id SQL else <<~SQL UPDATE spree_adjustments SET source_id = spree_promotion_actions.id, source_type = 'Spree::PromotionAction' FROM spree_promotion_actions INNER JOIN friendly_benefits ON friendly_benefits.original_promotion_action_id = spree_promotion_actions.id WHERE spree_adjustments.source_id = friendly_benefits.id and spree_adjustments.source_type = 'SolidusFriendlyPromotions::Benefit' SQL end execute(sql) end |
.up ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/solidus_friendly_promotions/migrate_adjustments.rb', line 6 def up sql = if ActiveRecord::Base.connection_db_config.adapter == "mysql2" <<~SQL UPDATE spree_adjustments INNER JOIN spree_promotion_actions ON spree_adjustments.source_id = spree_promotion_actions.id and spree_adjustments.source_type = 'Spree::PromotionAction' INNER JOIN friendly_benefits ON friendly_benefits.original_promotion_action_id = spree_promotion_actions.id SET source_id = friendly_benefits.id, source_type = 'SolidusFriendlyPromotions::Benefit' SQL else <<~SQL UPDATE spree_adjustments SET source_id = friendly_benefits.id, source_type = 'SolidusFriendlyPromotions::Benefit' FROM spree_promotion_actions INNER JOIN friendly_benefits ON friendly_benefits.original_promotion_action_id = spree_promotion_actions.id WHERE spree_adjustments.source_id = spree_promotion_actions.id and spree_adjustments.source_type = 'Spree::PromotionAction' SQL end execute(sql) end |