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
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/generators/saucy/install/templates/create_saucy_tables.rb', line 2
def self.up
create_table :memberships do |table|
table.integer :account_id
table.integer :user_id
table.boolean :admin, :null => false, :default => false
table.datetime :created_at
table.datetime :updated_at
end
add_index :memberships, [:account_id, :user_id], :unique => true
create_table :accounts do |table|
table.belongs_to :plan
table.string :name
table.string :keyword
table.datetime :created_at
table.datetime :updated_at
table.string :customer_token
table.string :subscription_token
table.string :subscription_status
table.datetime :next_billing_date
table.boolean :notified_of_disabling, :default => false, :null => false
table.boolean :notified_of_expiration, :default => false, :null => false
table.boolean :notified_of_completed_trial, :default => false, :null => false
table.boolean :asked_to_activate, :default => false, :null => false
table.boolean :activated, :default => false, :null => false
table.datetime :trial_expires_at
end
add_index :accounts, :plan_id
add_index :accounts, :keyword, :unique => true
add_index :accounts, :next_billing_date
add_index :accounts, :created_at
add_index :accounts, :trial_expires_at
create_table :invitations do |table|
table.string :email
table.integer :account_id
table.integer :sender_id
table.boolean :admin, :null => false, :default => false
table.string :code
table.boolean :used, :default => false, :null => false
table.datetime :created_at
table.datetime :updated_at
end
add_index :invitations, [:account_id]
create_table :permissions do |table|
table.integer :membership_id
table.integer :user_id
table.integer :project_id
table.datetime :created_at
table.datetime :updated_at
end
add_index :permissions, [:user_id, :project_id]
add_index :permissions, [:membership_id, :project_id], :name => [:membership_and_project], :unique => true
create_table :projects do |table|
table.string :name
table.string :keyword
table.integer :account_id
table.boolean :archived, :default => false, :null => false
table.datetime :created_at
table.datetime :updated_at
end
add_index :projects, [:keyword, :account_id], :unique => true
add_index :projects, :archived
change_table :users do |table|
table.string :name, :default => ""
end
create_table :plans do |t|
t.string :name
t.integer :price, :null => false, :default => 0
t.boolean :trial, :default => false, :null => false
t.timestamps
end
add_index :plans, :name
create_table :limits do |t|
t.belongs_to :plan
t.string :name
t.column :value, 'BIGINT UNSIGNED', :null => false, :default => 0
t.string :value_type, :null => false, :default => "number"
t.timestamps
end
add_index :limits, :plan_id
create_table :invitations_projects, :id => false do |table|
table.integer :invitation_id, :null => false
table.integer :project_id, :null => false
end
add_index :invitations_projects, [:invitation_id, :project_id], :unique => true
end
|