Class: ShopCartDurationMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/09_shop_cart_duration_task.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



15
16
# File 'lib/migrations/09_shop_cart_duration_task.rb', line 15

def self.down(site)
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/migrations/09_shop_cart_duration_task.rb', line 2

def self.up(site)
  # duration is now stored outside a cart
  site.carts.modify do |carts|
    remove_field :hold_duration
  end
  
  # clean up carts every minute
  cart_task = Task.new(site)
  cart_task.type = 'perform_destroy_stale_carts'
  cart_task.repeat_in = 60
  cart_task.save
end