class CreateMuckCommerce < ActiveRecord::Migration def self.up create_table :billing_informations, :force => true do |t| t.integer "billable_id" t.string "billable_type" t.string "first_name", :limit => 128, :default => "", :null => false t.string "last_name", :limit => 128, :default => "", :null => false t.string "address1", :limit => 512, :default => "", :null => false t.string "address2", :limit => 512 t.string "city", :limit => 128, :default => "", :null => false t.integer "state_id" t.integer "country_id" t.string "postal_code", :default => "", :null => false t.string "telephone", :default => "", :null => false t.string "payment_method", :default => 'CC' t.string "credit_card_type" t.string "credit_card_last_digits", :limit => 4 t.datetime "credit_card_expiration" t.string "achname", :limit => 1024 t.string "achrouting", :limit => 1024 t.string "achnumber", :limit => 1024 t.string "achholder", :limit => 1024 t.string "achtype", :limit => 64 t.string "vault_id", :limit => 512 t.string "customer_profile_id", :limit => 512 t.string "customer_payment_profile_id", :limit => 512 t.boolean "default", :default => false t.timestamps end add_index "billing_informations", ["billable_id", "billable_type"] create_table :carts, :force => true do |t| t.integer "cartable_id" t.string "cartable_type" t.string "token" t.timestamps end add_index "carts", ["cartable_id", "cartable_type"] create_table :cart_coupons, :force => true do |t| t.integer "cart_id" t.integer "coupon_id" t.timestamps end add_index "cart_coupons", ["cart_id", "coupon_id"] create_table :coupons, :force => true do |t| t.string "code" t.integer "amount", :default => 0, :null => false t.integer "percent", :default => 0, :null => false t.integer "uses", :default => 0, :null => false t.boolean "unlimited", :default => false, :null => false t.datetime "expires_at" t.integer "use_limit", :default => 1, :null => false t.timestamps end add_index "coupons", ["code"] create_table :order_transactions, :force => true do |t| t.integer "amount" t.boolean "success" t.string "reference" t.string "message" t.string "action" t.text "params" t.boolean "test" t.integer "transactionable_id" t.string "transactionable_type" t.integer "response_code" t.timestamps end add_index "order_transactions", ["transactionable_id"] create_table :orders, :force => true do |t| t.integer "orderable_id" t.string "orderable_type" t.integer "amount" t.integer "discount" t.string "number" t.string "first_name" t.string "last_name" t.string "ip_address" t.string "express_token" t.string "express_payer_id" t.string "order_type" t.timestamps end add_index "orders", ["orderable_id", "orderable_type"] create_table :order_coupons, :force => true do |t| t.integer "order_id" t.integer "coupon_id" t.timestamps end add_index "order_coupons", ["order_id", "coupon_id"] create_table :subscription_plans, :force => true do |t| t.string "name" t.string "sku" t.integer "amount" t.integer "renewal_period" t.integer "trial_period" t.timestamps end add_index "subscription_plans", ["name"] create_table :subscriptions, :force => true do |t| t.integer "user_id" t.integer "amount" t.datetime "next_renewal_at" t.string "aasm_state", :default => "trial" t.integer "subscription_plan_id" t.integer "renewal_period" t.string "number" t.integer "failed_billing_attempts", :default => 0, :null => false t.datetime "cancelled_at" t.datetime "suspended_at" t.datetime "activated_at" t.boolean "default", :default => false t.timestamps end add_index "subscriptions", ["user_id"] end def self.down drop_table :subscriptions drop_table :subscription_plans drop_table :orders drop_table :order_transactions drop_table :coupons drop_table :carts drop_table :billing_informations end end