Sha256: 5ba0ea288a676e387f66093b7a62466fb42203934e06fc9d32446eb44588aaca

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

class CreateEcommerceTables < ActiveRecord::Migration
  def self.up

    # Products
    create_table :products do |t|
      t.string :name, :null => false
      t.string :permalink, :null => false
      t.text :descr
      t.column :price, :decimal, :precision => 8, :scale => 2, :default => 0
      t.column :sale_price, :decimal, :precision => 8, :scale => 2, :default => 0
      t.text :meta_description
      t.text :meta_keywords
      t.string :tags
      t.integer :shipping_weight
      t.timestamps
    end

    # Each product has_many :photos
    create_table :photos do |t|
      t.integer :product_id
      t.string :photo_file_name
      t.string :photo_content_type
      t.integer :photo_file_size
      t.datetime :photo_updated_at
      t.timestamps
    end

    create_table :carts do |t|
      t.datetime :purchased_at
      t.timestamps
    end

    create_table :cart_items do |t|
      t.integer :cart_id
      t.integer :product_id
      t.integer :quantity
    end

    # PayPal -- how they let us know when a payment has cleared
    create_table :payment_handlers do |t|
      t.text :params
      t.integer :cart_id
      t.string :status
      t.string :transaction_id
      t.timestamps
    end

  end

  def self.down
    drop_table :products
    drop_table :photos
    drop_table :carts
    drop_table :cart_items
    drop_table :payment_handlers
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecommerce-0.0.6 lib/generators/ecommerce/templates/migration.rb
ecommerce-0.0.5 lib/generators/ecommerce/templates/migration.rb
ecommerce-0.0.4 lib/generators/ecommerce/templates/migration.rb
ecommerce-0.0.3 lib/generators/ecommerce/templates/migration.rb