Class: ShopProductModelMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/01_shop_product_model.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



13
14
15
# File 'lib/migrations/01_shop_product_model.rb', line 13

def self.down(site)
  site.products.destroy
end

.up(site) ⇒ Object



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

def self.up(site)
  site.pages.create_model :products do |products|
    add_field :price, :decimal, validations: {required: {}}, default: '0.0'
    add_field :shipping, :decimal, validations: {required: {}}, default: '0.0'
    add_field :tax, :decimal, validations: {required: {}}, default: '0.0'
    add_field :unlimited_quantity, :boolean, validations: {required: {}}, default: false
    add_field :quantity, :integer, validations: {required: {}}, default: 0, index: true
    add_many  :holds, model: :product_hold
  end
end