Sha256: 0910d4383dd074d975d137e4ef8a2baf042e551c96c2b376135aa896e707858d

Contents?: true

Size: 962 Bytes

Versions: 12

Compression:

Stored size: 962 Bytes

Contents

class CreateCarter < ActiveRecord::Migration
  def self.up
    create_table :carts do |t|
      t.string :session_id, :state
      t.belongs_to :shopper, :polymorphic => true
      t.timestamps
    end
    
    add_index :carts, :shopper_id
    add_index :carts, :state
    add_index :carts, :shopper_type
    
    create_table :cart_items do |t|
      t.string :name, :state
      t.belongs_to :cartable, :polymorphic => true
      t.belongs_to :owner, :polymorphic => true
      t.belongs_to :cart
      t.column :price, :float, :default => "0.00" 
      t.column :quantity, :integer
      t.timestamps
    end
    
    add_index :cart_items, :name
    add_index :cart_items, :state
    add_index :cart_items, :cartable_id
    add_index :cart_items, :cart_id
    add_index :cart_items, :cartable_type
    add_index :cart_items, :owner_id
    add_index :cart_items, :owner_type
  end

  def self.down
    drop_table :carts
    drop_table :cart_items
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
carter-0.8.1 lib/generators/carter/templates/migration.rb
carter-0.8.0 lib/generators/carter/templates/migration.rb
carter-0.7.2 generators/templates/migration.rb
carter-0.7.1 generators/templates/migration.rb
carter-0.7.0 generators/templates/migration.rb
carter-0.6.4 generators/templates/migration.rb
carter-0.6.3 generators/templates/migration.rb
carter-0.6.2 generators/templates/migration.rb
carter-0.6.1 generators/templates/migration.rb
carter-0.6.0 generators/templates/migration.rb
carter-0.5.6 generators/templates/migration.rb
carter-0.5.5 generators/templates/migration.rb