]> Untitled Git - lemmy.git/blob - lemmy_db/src/schema.rs
33e2389fdb929be0ee7d4954d03fc7b45e8f8a34
[lemmy.git] / lemmy_db / src / schema.rs
1 table! {
2     activity (id) {
3         id -> Int4,
4         data -> Jsonb,
5         local -> Bool,
6         published -> Timestamp,
7         updated -> Nullable<Timestamp>,
8         ap_id -> Nullable<Text>,
9         sensitive -> Nullable<Bool>,
10     }
11 }
12
13 table! {
14     category (id) {
15         id -> Int4,
16         name -> Varchar,
17     }
18 }
19
20 table! {
21     comment (id) {
22         id -> Int4,
23         creator_id -> Int4,
24         post_id -> Int4,
25         parent_id -> Nullable<Int4>,
26         content -> Text,
27         removed -> Bool,
28         read -> Bool,
29         published -> Timestamp,
30         updated -> Nullable<Timestamp>,
31         deleted -> Bool,
32         ap_id -> Varchar,
33         local -> Bool,
34     }
35 }
36
37 table! {
38     comment_aggregates (id) {
39         id -> Int4,
40         comment_id -> Int4,
41         score -> Int8,
42         upvotes -> Int8,
43         downvotes -> Int8,
44     }
45 }
46
47 table! {
48     comment_like (id) {
49         id -> Int4,
50         user_id -> Int4,
51         comment_id -> Int4,
52         post_id -> Int4,
53         score -> Int2,
54         published -> Timestamp,
55     }
56 }
57
58 table! {
59     comment_report (id) {
60         id -> Int4,
61         creator_id -> Int4,
62         comment_id -> Int4,
63         original_comment_text -> Text,
64         reason -> Text,
65         resolved -> Bool,
66         resolver_id -> Nullable<Int4>,
67         published -> Timestamp,
68         updated -> Nullable<Timestamp>,
69     }
70 }
71
72 table! {
73     comment_saved (id) {
74         id -> Int4,
75         comment_id -> Int4,
76         user_id -> Int4,
77         published -> Timestamp,
78     }
79 }
80
81 table! {
82     community (id) {
83         id -> Int4,
84         name -> Varchar,
85         title -> Varchar,
86         description -> Nullable<Text>,
87         category_id -> Int4,
88         creator_id -> Int4,
89         removed -> Bool,
90         published -> Timestamp,
91         updated -> Nullable<Timestamp>,
92         deleted -> Bool,
93         nsfw -> Bool,
94         actor_id -> Varchar,
95         local -> Bool,
96         private_key -> Nullable<Text>,
97         public_key -> Nullable<Text>,
98         last_refreshed_at -> Timestamp,
99         icon -> Nullable<Text>,
100         banner -> Nullable<Text>,
101     }
102 }
103
104 table! {
105     community_aggregates (id) {
106         id -> Int4,
107         community_id -> Int4,
108         subscribers -> Int8,
109         posts -> Int8,
110         comments -> Int8,
111     }
112 }
113
114 table! {
115     community_follower (id) {
116         id -> Int4,
117         community_id -> Int4,
118         user_id -> Int4,
119         published -> Timestamp,
120         pending -> Nullable<Bool>,
121     }
122 }
123
124 table! {
125     community_moderator (id) {
126         id -> Int4,
127         community_id -> Int4,
128         user_id -> Int4,
129         published -> Timestamp,
130     }
131 }
132
133 table! {
134     community_user_ban (id) {
135         id -> Int4,
136         community_id -> Int4,
137         user_id -> Int4,
138         published -> Timestamp,
139     }
140 }
141
142 table! {
143     mod_add (id) {
144         id -> Int4,
145         mod_user_id -> Int4,
146         other_user_id -> Int4,
147         removed -> Nullable<Bool>,
148         when_ -> Timestamp,
149     }
150 }
151
152 table! {
153     mod_add_community (id) {
154         id -> Int4,
155         mod_user_id -> Int4,
156         other_user_id -> Int4,
157         community_id -> Int4,
158         removed -> Nullable<Bool>,
159         when_ -> Timestamp,
160     }
161 }
162
163 table! {
164     mod_ban (id) {
165         id -> Int4,
166         mod_user_id -> Int4,
167         other_user_id -> Int4,
168         reason -> Nullable<Text>,
169         banned -> Nullable<Bool>,
170         expires -> Nullable<Timestamp>,
171         when_ -> Timestamp,
172     }
173 }
174
175 table! {
176     mod_ban_from_community (id) {
177         id -> Int4,
178         mod_user_id -> Int4,
179         other_user_id -> Int4,
180         community_id -> Int4,
181         reason -> Nullable<Text>,
182         banned -> Nullable<Bool>,
183         expires -> Nullable<Timestamp>,
184         when_ -> Timestamp,
185     }
186 }
187
188 table! {
189     mod_lock_post (id) {
190         id -> Int4,
191         mod_user_id -> Int4,
192         post_id -> Int4,
193         locked -> Nullable<Bool>,
194         when_ -> Timestamp,
195     }
196 }
197
198 table! {
199     mod_remove_comment (id) {
200         id -> Int4,
201         mod_user_id -> Int4,
202         comment_id -> Int4,
203         reason -> Nullable<Text>,
204         removed -> Nullable<Bool>,
205         when_ -> Timestamp,
206     }
207 }
208
209 table! {
210     mod_remove_community (id) {
211         id -> Int4,
212         mod_user_id -> Int4,
213         community_id -> Int4,
214         reason -> Nullable<Text>,
215         removed -> Nullable<Bool>,
216         expires -> Nullable<Timestamp>,
217         when_ -> Timestamp,
218     }
219 }
220
221 table! {
222     mod_remove_post (id) {
223         id -> Int4,
224         mod_user_id -> Int4,
225         post_id -> Int4,
226         reason -> Nullable<Text>,
227         removed -> Nullable<Bool>,
228         when_ -> Timestamp,
229     }
230 }
231
232 table! {
233     mod_sticky_post (id) {
234         id -> Int4,
235         mod_user_id -> Int4,
236         post_id -> Int4,
237         stickied -> Nullable<Bool>,
238         when_ -> Timestamp,
239     }
240 }
241
242 table! {
243     password_reset_request (id) {
244         id -> Int4,
245         user_id -> Int4,
246         token_encrypted -> Text,
247         published -> Timestamp,
248     }
249 }
250
251 table! {
252     post (id) {
253         id -> Int4,
254         name -> Varchar,
255         url -> Nullable<Text>,
256         body -> Nullable<Text>,
257         creator_id -> Int4,
258         community_id -> Int4,
259         removed -> Bool,
260         locked -> Bool,
261         published -> Timestamp,
262         updated -> Nullable<Timestamp>,
263         deleted -> Bool,
264         nsfw -> Bool,
265         stickied -> Bool,
266         embed_title -> Nullable<Text>,
267         embed_description -> Nullable<Text>,
268         embed_html -> Nullable<Text>,
269         thumbnail_url -> Nullable<Text>,
270         ap_id -> Varchar,
271         local -> Bool,
272     }
273 }
274
275 table! {
276     post_aggregates (id) {
277         id -> Int4,
278         post_id -> Int4,
279         comments -> Int8,
280         score -> Int8,
281         upvotes -> Int8,
282         downvotes -> Int8,
283         newest_comment_time -> Timestamp,
284     }
285 }
286
287 table! {
288     post_like (id) {
289         id -> Int4,
290         post_id -> Int4,
291         user_id -> Int4,
292         score -> Int2,
293         published -> Timestamp,
294     }
295 }
296
297 table! {
298     post_read (id) {
299         id -> Int4,
300         post_id -> Int4,
301         user_id -> Int4,
302         published -> Timestamp,
303     }
304 }
305
306 table! {
307     post_report (id) {
308         id -> Int4,
309         creator_id -> Int4,
310         post_id -> Int4,
311         original_post_name -> Varchar,
312         original_post_url -> Nullable<Text>,
313         original_post_body -> Nullable<Text>,
314         reason -> Text,
315         resolved -> Bool,
316         resolver_id -> Nullable<Int4>,
317         published -> Timestamp,
318         updated -> Nullable<Timestamp>,
319     }
320 }
321
322 table! {
323     post_saved (id) {
324         id -> Int4,
325         post_id -> Int4,
326         user_id -> Int4,
327         published -> Timestamp,
328     }
329 }
330
331 table! {
332     private_message (id) {
333         id -> Int4,
334         creator_id -> Int4,
335         recipient_id -> Int4,
336         content -> Text,
337         deleted -> Bool,
338         read -> Bool,
339         published -> Timestamp,
340         updated -> Nullable<Timestamp>,
341         ap_id -> Varchar,
342         local -> Bool,
343     }
344 }
345
346 table! {
347     site (id) {
348         id -> Int4,
349         name -> Varchar,
350         description -> Nullable<Text>,
351         creator_id -> Int4,
352         published -> Timestamp,
353         updated -> Nullable<Timestamp>,
354         enable_downvotes -> Bool,
355         open_registration -> Bool,
356         enable_nsfw -> Bool,
357         icon -> Nullable<Text>,
358         banner -> Nullable<Text>,
359     }
360 }
361
362 table! {
363     site_aggregates (id) {
364         id -> Int4,
365         users -> Int8,
366         posts -> Int8,
367         comments -> Int8,
368         communities -> Int8,
369     }
370 }
371
372 table! {
373     user_ (id) {
374         id -> Int4,
375         name -> Varchar,
376         preferred_username -> Nullable<Varchar>,
377         password_encrypted -> Text,
378         email -> Nullable<Text>,
379         avatar -> Nullable<Text>,
380         admin -> Bool,
381         banned -> Bool,
382         published -> Timestamp,
383         updated -> Nullable<Timestamp>,
384         show_nsfw -> Bool,
385         theme -> Varchar,
386         default_sort_type -> Int2,
387         default_listing_type -> Int2,
388         lang -> Varchar,
389         show_avatars -> Bool,
390         send_notifications_to_email -> Bool,
391         matrix_user_id -> Nullable<Text>,
392         actor_id -> Varchar,
393         bio -> Nullable<Text>,
394         local -> Bool,
395         private_key -> Nullable<Text>,
396         public_key -> Nullable<Text>,
397         last_refreshed_at -> Timestamp,
398         banner -> Nullable<Text>,
399         deleted -> Bool,
400     }
401 }
402
403 table! {
404     user_aggregates (id) {
405         id -> Int4,
406         user_id -> Int4,
407         post_count -> Int8,
408         post_score -> Int8,
409         comment_count -> Int8,
410         comment_score -> Int8,
411     }
412 }
413
414 table! {
415     user_ban (id) {
416         id -> Int4,
417         user_id -> Int4,
418         published -> Timestamp,
419     }
420 }
421
422 table! {
423     user_mention (id) {
424         id -> Int4,
425         recipient_id -> Int4,
426         comment_id -> Int4,
427         read -> Bool,
428         published -> Timestamp,
429     }
430 }
431
432 // These are necessary since diesel doesn't have self joins / aliases
433 table! {
434     comment_alias_1 (id) {
435         id -> Int4,
436         creator_id -> Int4,
437         post_id -> Int4,
438         parent_id -> Nullable<Int4>,
439         content -> Text,
440         removed -> Bool,
441         read -> Bool,
442         published -> Timestamp,
443         updated -> Nullable<Timestamp>,
444         deleted -> Bool,
445         ap_id -> Varchar,
446         local -> Bool,
447     }
448 }
449
450 table! {
451     user_alias_1 (id) {
452         id -> Int4,
453         name -> Varchar,
454         preferred_username -> Nullable<Varchar>,
455         password_encrypted -> Text,
456         email -> Nullable<Text>,
457         avatar -> Nullable<Text>,
458         admin -> Bool,
459         banned -> Bool,
460         published -> Timestamp,
461         updated -> Nullable<Timestamp>,
462         show_nsfw -> Bool,
463         theme -> Varchar,
464         default_sort_type -> Int2,
465         default_listing_type -> Int2,
466         lang -> Varchar,
467         show_avatars -> Bool,
468         send_notifications_to_email -> Bool,
469         matrix_user_id -> Nullable<Text>,
470         actor_id -> Varchar,
471         bio -> Nullable<Text>,
472         local -> Bool,
473         private_key -> Nullable<Text>,
474         public_key -> Nullable<Text>,
475         last_refreshed_at -> Timestamp,
476         banner -> Nullable<Text>,
477         deleted -> Bool,
478     }
479 }
480
481 table! {
482     user_alias_2 (id) {
483         id -> Int4,
484         name -> Varchar,
485         preferred_username -> Nullable<Varchar>,
486         password_encrypted -> Text,
487         email -> Nullable<Text>,
488         avatar -> Nullable<Text>,
489         admin -> Bool,
490         banned -> Bool,
491         published -> Timestamp,
492         updated -> Nullable<Timestamp>,
493         show_nsfw -> Bool,
494         theme -> Varchar,
495         default_sort_type -> Int2,
496         default_listing_type -> Int2,
497         lang -> Varchar,
498         show_avatars -> Bool,
499         send_notifications_to_email -> Bool,
500         matrix_user_id -> Nullable<Text>,
501         actor_id -> Varchar,
502         bio -> Nullable<Text>,
503         local -> Bool,
504         private_key -> Nullable<Text>,
505         public_key -> Nullable<Text>,
506         last_refreshed_at -> Timestamp,
507         banner -> Nullable<Text>,
508         deleted -> Bool,
509     }
510 }
511
512 joinable!(comment_alias_1 -> user_alias_1 (creator_id));
513 joinable!(comment -> comment_alias_1 (parent_id));
514 joinable!(user_mention -> user_alias_1 (recipient_id));
515 joinable!(post -> user_alias_1 (creator_id));
516 joinable!(comment -> user_alias_1 (creator_id));
517
518 joinable!(post_report -> user_alias_2 (resolver_id));
519 joinable!(comment_report -> user_alias_2 (resolver_id));
520
521 joinable!(comment -> post (post_id));
522 joinable!(comment -> user_ (creator_id));
523 joinable!(comment_aggregates -> comment (comment_id));
524 joinable!(comment_like -> comment (comment_id));
525 joinable!(comment_like -> post (post_id));
526 joinable!(comment_like -> user_ (user_id));
527 joinable!(comment_report -> comment (comment_id));
528 joinable!(comment_saved -> comment (comment_id));
529 joinable!(comment_saved -> user_ (user_id));
530 joinable!(community -> category (category_id));
531 joinable!(community -> user_ (creator_id));
532 joinable!(community_aggregates -> community (community_id));
533 joinable!(community_follower -> community (community_id));
534 joinable!(community_follower -> user_ (user_id));
535 joinable!(community_moderator -> community (community_id));
536 joinable!(community_moderator -> user_ (user_id));
537 joinable!(community_user_ban -> community (community_id));
538 joinable!(community_user_ban -> user_ (user_id));
539 joinable!(mod_add_community -> community (community_id));
540 joinable!(mod_ban_from_community -> community (community_id));
541 joinable!(mod_lock_post -> post (post_id));
542 joinable!(mod_lock_post -> user_ (mod_user_id));
543 joinable!(mod_remove_comment -> comment (comment_id));
544 joinable!(mod_remove_comment -> user_ (mod_user_id));
545 joinable!(mod_remove_community -> community (community_id));
546 joinable!(mod_remove_community -> user_ (mod_user_id));
547 joinable!(mod_remove_post -> post (post_id));
548 joinable!(mod_remove_post -> user_ (mod_user_id));
549 joinable!(mod_sticky_post -> post (post_id));
550 joinable!(mod_sticky_post -> user_ (mod_user_id));
551 joinable!(password_reset_request -> user_ (user_id));
552 joinable!(post -> community (community_id));
553 joinable!(post -> user_ (creator_id));
554 joinable!(post_aggregates -> post (post_id));
555 joinable!(post_like -> post (post_id));
556 joinable!(post_like -> user_ (user_id));
557 joinable!(post_read -> post (post_id));
558 joinable!(post_read -> user_ (user_id));
559 joinable!(post_report -> post (post_id));
560 joinable!(post_saved -> post (post_id));
561 joinable!(post_saved -> user_ (user_id));
562 joinable!(site -> user_ (creator_id));
563 joinable!(user_aggregates -> user_ (user_id));
564 joinable!(user_ban -> user_ (user_id));
565 joinable!(user_mention -> comment (comment_id));
566 joinable!(user_mention -> user_ (recipient_id));
567
568 allow_tables_to_appear_in_same_query!(
569   activity,
570   category,
571   comment,
572   comment_aggregates,
573   comment_like,
574   comment_report,
575   comment_saved,
576   community,
577   community_aggregates,
578   community_follower,
579   community_moderator,
580   community_user_ban,
581   mod_add,
582   mod_add_community,
583   mod_ban,
584   mod_ban_from_community,
585   mod_lock_post,
586   mod_remove_comment,
587   mod_remove_community,
588   mod_remove_post,
589   mod_sticky_post,
590   password_reset_request,
591   post,
592   post_aggregates,
593   post_like,
594   post_read,
595   post_report,
596   post_saved,
597   private_message,
598   site,
599   site_aggregates,
600   user_,
601   user_aggregates,
602   user_ban,
603   user_mention,
604   comment_alias_1,
605   user_alias_1,
606   user_alias_2,
607 );