/
20111114213015_create_social_stream.rb
319 lines (248 loc) · 10.5 KB
/
20111114213015_create_social_stream.rb
1
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
class CreateSocialStream < ActiveRecord::Migration
def self.up
create_table "activities", :force => true do |t|
t.integer "contact_id"
t.integer "activity_verb_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "ancestry"
end
add_index "activities", "contact_id"
add_index "activities", "activity_verb_id"
create_table "activity_object_activities", :force => true do |t|
t.integer "activity_id"
t.integer "activity_object_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "object_type"
end
add_index "activity_object_activities", "activity_id"
add_index "activity_object_activities", "activity_object_id"
create_table "activity_objects", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "object_type", :limit => 45
t.integer "like_count", :default => 0
end
create_table "activity_verbs", :force => true do |t|
t.string "name", :limit => 45
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "actors", :force => true do |t|
t.string "name"
t.string "email", :default => "", :null => false
t.string "slug"
t.string "subject_type"
t.boolean "notify_by_email", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.integer "activity_object_id"
t.integer "follower_count", :default => 0
end
add_index "actors", "activity_object_id"
add_index "actors", "email"
add_index "actors", "slug", :unique => true
create_table "audiences", :force => true do |t|
t.integer "relation_id"
t.integer "activity_id"
end
add_index "audiences", "relation_id"
add_index "audiences", "activity_id"
create_table :authentications, :force => true do |t|
t.integer :user_id
t.string :provider
t.string :uid
t.timestamps
end
add_index "authentications", "user_id"
create_table "avatars", :force => true do |t|
t.integer "actor_id"
t.string "logo_file_name"
t.string "logo_content_type"
t.integer "logo_file_size"
t.datetime "logo_updated_at"
t.boolean "active", :default => true
end
add_index "avatars", "actor_id"
create_table "comments", :force => true do |t|
t.integer "activity_object_id"
t.text "text"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "comments", "activity_object_id"
create_table "contacts", :force => true do |t|
t.integer "sender_id"
t.integer "receiver_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "inverse_id"
t.integer "ties_count"
end
add_index "contacts", "receiver_id"
add_index "contacts", "sender_id"
add_index "contacts", "inverse_id"
create_table "groups", :force => true do |t|
t.integer "actor_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "groups", "actor_id"
create_table "permissions", :force => true do |t|
t.string "action"
t.string "object", :default => nil
t.string "function", :default => nil
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "posts", :force => true do |t|
t.integer "activity_object_id"
t.datetime "created_at"
t.datetime "updated_at"
t.text "text"
end
add_index "posts", "activity_object_id"
create_table "profiles", :force => true do |t|
t.integer "actor_id"
t.date "birthday"
t.datetime "created_at"
t.datetime "updated_at"
t.string "organization", :limit => 45
t.string "phone", :limit => 45
t.string "mobile", :limit => 45
t.string "fax", :limit => 45
t.string "address"
t.string "city"
t.string "zipcode", :limit => 45
t.string "province", :limit => 45
t.string "country", :limit => 45
t.integer "prefix_key"
t.string "description"
t.string "experience"
t.string "website"
t.string "skype", :limit => 45
t.string "im", :limit => 45
end
add_index "profiles", "actor_id"
create_table "relation_permissions", :force => true do |t|
t.integer "relation_id"
t.integer "permission_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "relation_id"
end
add_index "relation_permissions", "relation_id"
add_index "relation_permissions", "permission_id"
create_table "relations", :force => true do |t|
t.integer "actor_id"
t.string "type"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "sender_type"
t.string "receiver_type"
t.string "ancestry"
t.integer "sphere_id"
end
add_index "relations", "actor_id"
add_index "relations", "ancestry"
add_index "relations", "sphere_id"
create_table "spheres", :force => true do |t|
t.string "name"
t.integer "actor_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "spheres", "actor_id"
create_table "ties", :force => true do |t|
t.integer "contact_id"
t.integer "relation_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "ties", "contact_id"
add_index "ties", "relation_id"
create_table "users", :force => true do |t|
t.string :encrypted_password, :null => false, :default => "", :limit => 128
t.string :password_salt
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
t.token_authenticatable
t.timestamps
t.integer "actor_id"
end
add_index "users", "actor_id"
add_index "users", :reset_password_token, :unique => true
# add_index :users, :confirmation_token, :unique => true
# add_index :users, :unlock_token, :unique => true
add_foreign_key "activities", "contacts", :name => "index_activities_on_contact_id"
add_foreign_key "activities", "activity_verbs", :name => "index_activities_on_activity_verb_id"
add_foreign_key "activity_object_activities", "activities", :name => "index_activity_object_activities_on_activity_id"
add_foreign_key "activity_object_activities", "activity_objects", :name => "activity_object_activities_on_activity_object_id"
add_foreign_key "actors", "activity_objects", :name => "actors_on_activity_object_id"
add_foreign_key "audiences", "relations", :name => "audiences_on_relation_id"
add_foreign_key "audiences", "activities", :name => "audiences_on_activity_id"
add_foreign_key "authentications", "users", :name => "authentications_on_user_id"
add_foreign_key "avatars", "actors", :name => "avatars_on_actor_id"
add_foreign_key "comments", "activity_objects", :name => "comments_on_activity_object_id"
add_foreign_key "contacts", "actors", :name => "contacts_on_receiver_id", :column => "receiver_id"
add_foreign_key "contacts", "actors", :name => "contacts_on_sender_id", :column => "sender_id"
add_foreign_key "groups", "actors", :name => "groups_on_actor_id"
add_foreign_key "posts", "activity_objects", :name => "posts_on_activity_object_id"
add_foreign_key "profiles", "actors", :name => "profiles_on_actor_id"
add_foreign_key "relation_permissions", "relations", :name => "relation_permissions_on_relation_id"
add_foreign_key "relation_permissions", "permissions", :name => "relation_permissions_on_permission_id"
add_foreign_key "relations", "actors", :name => "relations_on_actor_id"
add_foreign_key "relations", "spheres", :name => "relations_on_sphere_id"
add_foreign_key "spheres", "actors", :name => "spheres_on_actor_id"
add_foreign_key "ties", "contacts", :name => "ties_on_contact_id"
add_foreign_key "ties", "relations", :name => "ties_on_relation_id"
add_foreign_key "users", "actors", :name => "users_on_actor_id"
end
def self.down
remove_foreign_key "activities", :name => "index_activities_on_activity_verb_id"
remove_foreign_key "activity_object_activities", :name => "index_activity_object_activities_on_activity_id"
remove_foreign_key "activity_object_activities", :name => "activity_object_activities_on_activity_object_id"
remove_foreign_key "actors", :name => "actors_on_activity_object_id"
remove_foreign_key "audiences", :name => "audiences_on_relation_id"
remove_foreign_key "audiences", :name => "audiences_on_activity_id"
remove_foreign_key "authentications", :name => "authentications_on_user_id"
remove_foreign_key "avatars", :name => "avatars_on_actor_id"
remove_foreign_key "comments", :name => "comments_on_activity_object_id"
remove_foreign_key "contacts", :name => "contacts_on_receiver_id", :column => "receiver_id"
remove_foreign_key "contacts", :name => "contacts_on_sender_id", :column => "sender_id"
remove_foreign_key "groups", :name => "groups_on_actor_id"
remove_foreign_key "posts", :name => "posts_on_activity_object_id"
remove_foreign_key "profiles", :name => "profiles_on_actor_id"
remove_foreign_key "relation_permissions", :name => "relation_permissions_on_relation_id"
remove_foreign_key "relation_permissions", :name => "relation_permissions_on_permission_id"
remove_foreign_key "relations", :name => "relations_on_actor_id"
remove_foreign_key "relations", :name => "relations_on_sphere_id"
remove_foreign_key "spheres", :name => "spheres_on_actor_id"
remove_foreign_key "ties", :name => "ties_on_contact_id"
remove_foreign_key "ties", :name => "ties_on_relation_id"
remove_foreign_key "users", :name => "users_on_actor_id"
drop_table :activities
drop_table :activity_object_activities
drop_table :activity_objects
drop_table :activity_verbs
drop_table :actors
drop_table :authentications
drop_table :avatars
drop_table :comments
drop_table :contacts
drop_table :groups
drop_table :permissions
drop_table :posts
drop_table :profiles
drop_table :relation_permissions
drop_table :relations
drop_table :spheres
drop_table :ties
drop_table :users
end
end