Add purchases table
[cs356-p2-videostore.git] / db / migrate / 016_create_purchases.rb
1 class CreatePurchases < ActiveRecord::Migration
2   def self.up
3     create_table :purchases do |t|
4       # STI Required
5       t.column :type, :string
6
7       # Both
8       t.column :customer_id, :integer
9       t.column :date, :date
10       t.column :price, :decimal, :precision => 8, :scale => 2, :default => 0
11
12       # RentablePurchase only
13       t.column :rentable_id, :integer
14       t.column :due_date, :date
15
16       # MerchandisePurchase only
17       t.column :merchandise_id, :integer
18       t.column :quantity, :integer
19     end
20   end
21
22   def self.down
23     drop_table :purchases
24   end
25 end