Class: ShopCouponModelMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/06_shop_coupon_model.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



14
15
16
17
# File 'lib/migrations/06_shop_coupon_model.rb', line 14

def self.down(site)
  site.coupons.destroy
  site.coupon_redemptions.destroy
end

.up(site) ⇒ Object



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

def self.up(site)
  site.records.create_model :coupons do |coupons|
    add_field :code, :string
    add_field :value, :decimal
  end
  
  site.records.create_model :coupon_redemptions do |coupon_redemptions|
    add_one :user
    add_one :coupon
  end
end