Class: CreateSaasaparillaTables

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/saasaparilla/install/templates/create_saasaparilla_tables.rb

Class Method Summary collapse

Class Method Details

.downObject



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/generators/saasaparilla/install/templates/create_saasaparilla_tables.rb', line 93

def self.down

  drop_table :subscriptions
  drop_table :credit_cards
  drop_table :transactions
  drop_table :contact_infos
  drop_table :plans
  drop_table :payments
  drop_table :invoices
  drop_table :invoice_line_items
  drop_table :billing_activities
  
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/generators/saasaparilla/install/templates/create_saasaparilla_tables.rb', line 2

def self.up
  create_table :subscriptions do |t|
    t.integer :billable_id
    t.string :billable_type
    t.float :balance
    t.string :status
    t.integer :customer_cim_id
    t.integer :customer_payment_profile_id
    t.date :billing_date
    t.date :invoiced_on
    t.date :overdue_on
    t.boolean :no_charge, :default => false
    t.integer :plan_id
    t.integer :downgrade_to_plan_id
    t.timestamps
  end
  
  create_table :credit_cards do |t|
    t.string :expiration_date
    t.string :card_number
    t.integer :subscription_id
  end

  
  create_table :plans do |t|
    t.string :name
    t.string :billing_period
    t.integer :subscription_id
    t.float :price
    t.text :dynamic_attributes
    t.timestamps
  end
  
  create_table :contact_infos do |t|
    t.string :first_name
    t.string :last_name
    t.string :email
    t.string :company
    t.string :address
    t.string :city
    t.string :state
    t.string :zip
    t.string :country
    t.string :phone_number
  
    t.integer :subscription_id
  end
  
  create_table :billing_activities do |t|
    t.float :amount
    t.string :message
    t.integer :subscription_id
    t.timestamps
  end
  create_table :payments do |t|
    t.float :amount
    t.integer :subscription_id
    t.string :status
    t.timestamps
    
  end
  create_table :invoices do |t|
    t.float :total
    t.integer :invoice_number
    t.integer :billing_activity_id
    t.timestamps
  end
  
  create_table :invoice_line_items do |t|
    t.string :description
    t.date :from
    t.date :to
    t.float :price
    t.integer :invoice_id
  end
  
  create_table :transactions do |t|
     t.string :action
     t.float :amount
     t.boolean :success
     t.string :authorization
     t.string :message
     t.text :params
     t.integer :billing_activity_id
     t.integer :subscription_id
     t.timestamps
  end
  
  
end