Class: CouponRestrictionsMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/10_shop_coupon_restrictions.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/migrations/10_shop_coupon_restrictions.rb', line 13

def self.down(site)
  site.coupons.modify do |coupons|
    remove_field :user_restrictions
    remove_field :product_restrictions
    remove_field :value_type
    remove_field :redemptions
  end
end

.up(site) ⇒ Object



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

def self.up(site)
  site.coupon_redemptions.destroy
  
  site.coupons.modify do |coupons|
    add_field :user_restrictions, :hash
    add_field :product_restrictions, :hash
    add_field :value_type, :enum, options: %w{currency percent}, default: 'currency'
    add_many  :redemptions, model: :user
  end
end