]> Untitled Git - lemmy.git/blob - lemmy_db/src/schema.rs
Beginning to add new comment_view.
[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_aggregates_fast (id) {
49         id -> Int4,
50         creator_id -> Nullable<Int4>,
51         post_id -> Nullable<Int4>,
52         parent_id -> Nullable<Int4>,
53         content -> Nullable<Text>,
54         removed -> Nullable<Bool>,
55         read -> Nullable<Bool>,
56         published -> Nullable<Timestamp>,
57         updated -> Nullable<Timestamp>,
58         deleted -> Nullable<Bool>,
59         ap_id -> Nullable<Varchar>,
60         local -> Nullable<Bool>,
61         post_name -> Nullable<Varchar>,
62         community_id -> Nullable<Int4>,
63         community_actor_id -> Nullable<Varchar>,
64         community_local -> Nullable<Bool>,
65         community_name -> Nullable<Varchar>,
66         community_icon -> Nullable<Text>,
67         banned -> Nullable<Bool>,
68         banned_from_community -> Nullable<Bool>,
69         creator_actor_id -> Nullable<Varchar>,
70         creator_local -> Nullable<Bool>,
71         creator_name -> Nullable<Varchar>,
72         creator_preferred_username -> Nullable<Varchar>,
73         creator_published -> Nullable<Timestamp>,
74         creator_avatar -> Nullable<Text>,
75         score -> Nullable<Int8>,
76         upvotes -> Nullable<Int8>,
77         downvotes -> Nullable<Int8>,
78         hot_rank -> Nullable<Int4>,
79         hot_rank_active -> Nullable<Int4>,
80     }
81 }
82
83 table! {
84     comment_like (id) {
85         id -> Int4,
86         user_id -> Int4,
87         comment_id -> Int4,
88         post_id -> Int4,
89         score -> Int2,
90         published -> Timestamp,
91     }
92 }
93
94 table! {
95     comment_report (id) {
96         id -> Int4,
97         creator_id -> Int4,
98         comment_id -> Int4,
99         original_comment_text -> Text,
100         reason -> Text,
101         resolved -> Bool,
102         resolver_id -> Nullable<Int4>,
103         published -> Timestamp,
104         updated -> Nullable<Timestamp>,
105     }
106 }
107
108 table! {
109     comment_saved (id) {
110         id -> Int4,
111         comment_id -> Int4,
112         user_id -> Int4,
113         published -> Timestamp,
114     }
115 }
116
117 table! {
118     community (id) {
119         id -> Int4,
120         name -> Varchar,
121         title -> Varchar,
122         description -> Nullable<Text>,
123         category_id -> Int4,
124         creator_id -> Int4,
125         removed -> Bool,
126         published -> Timestamp,
127         updated -> Nullable<Timestamp>,
128         deleted -> Bool,
129         nsfw -> Bool,
130         actor_id -> Varchar,
131         local -> Bool,
132         private_key -> Nullable<Text>,
133         public_key -> Nullable<Text>,
134         last_refreshed_at -> Timestamp,
135         icon -> Nullable<Text>,
136         banner -> Nullable<Text>,
137     }
138 }
139
140 table! {
141     community_aggregates (id) {
142         id -> Int4,
143         community_id -> Int4,
144         subscribers -> Int8,
145         posts -> Int8,
146         comments -> Int8,
147     }
148 }
149
150 table! {
151     community_aggregates_fast (id) {
152         id -> Int4,
153         name -> Nullable<Varchar>,
154         title -> Nullable<Varchar>,
155         icon -> Nullable<Text>,
156         banner -> Nullable<Text>,
157         description -> Nullable<Text>,
158         category_id -> Nullable<Int4>,
159         creator_id -> Nullable<Int4>,
160         removed -> Nullable<Bool>,
161         published -> Nullable<Timestamp>,
162         updated -> Nullable<Timestamp>,
163         deleted -> Nullable<Bool>,
164         nsfw -> Nullable<Bool>,
165         actor_id -> Nullable<Varchar>,
166         local -> Nullable<Bool>,
167         last_refreshed_at -> Nullable<Timestamp>,
168         creator_actor_id -> Nullable<Varchar>,
169         creator_local -> Nullable<Bool>,
170         creator_name -> Nullable<Varchar>,
171         creator_preferred_username -> Nullable<Varchar>,
172         creator_avatar -> Nullable<Text>,
173         category_name -> Nullable<Varchar>,
174         number_of_subscribers -> Nullable<Int8>,
175         number_of_posts -> Nullable<Int8>,
176         number_of_comments -> Nullable<Int8>,
177         hot_rank -> Nullable<Int4>,
178     }
179 }
180
181 table! {
182     community_follower (id) {
183         id -> Int4,
184         community_id -> Int4,
185         user_id -> Int4,
186         published -> Timestamp,
187         pending -> Nullable<Bool>,
188     }
189 }
190
191 table! {
192     community_moderator (id) {
193         id -> Int4,
194         community_id -> Int4,
195         user_id -> Int4,
196         published -> Timestamp,
197     }
198 }
199
200 table! {
201     community_user_ban (id) {
202         id -> Int4,
203         community_id -> Int4,
204         user_id -> Int4,
205         published -> Timestamp,
206     }
207 }
208
209 table! {
210     mod_add (id) {
211         id -> Int4,
212         mod_user_id -> Int4,
213         other_user_id -> Int4,
214         removed -> Nullable<Bool>,
215         when_ -> Timestamp,
216     }
217 }
218
219 table! {
220     mod_add_community (id) {
221         id -> Int4,
222         mod_user_id -> Int4,
223         other_user_id -> Int4,
224         community_id -> Int4,
225         removed -> Nullable<Bool>,
226         when_ -> Timestamp,
227     }
228 }
229
230 table! {
231     mod_ban (id) {
232         id -> Int4,
233         mod_user_id -> Int4,
234         other_user_id -> Int4,
235         reason -> Nullable<Text>,
236         banned -> Nullable<Bool>,
237         expires -> Nullable<Timestamp>,
238         when_ -> Timestamp,
239     }
240 }
241
242 table! {
243     mod_ban_from_community (id) {
244         id -> Int4,
245         mod_user_id -> Int4,
246         other_user_id -> Int4,
247         community_id -> Int4,
248         reason -> Nullable<Text>,
249         banned -> Nullable<Bool>,
250         expires -> Nullable<Timestamp>,
251         when_ -> Timestamp,
252     }
253 }
254
255 table! {
256     mod_lock_post (id) {
257         id -> Int4,
258         mod_user_id -> Int4,
259         post_id -> Int4,
260         locked -> Nullable<Bool>,
261         when_ -> Timestamp,
262     }
263 }
264
265 table! {
266     mod_remove_comment (id) {
267         id -> Int4,
268         mod_user_id -> Int4,
269         comment_id -> Int4,
270         reason -> Nullable<Text>,
271         removed -> Nullable<Bool>,
272         when_ -> Timestamp,
273     }
274 }
275
276 table! {
277     mod_remove_community (id) {
278         id -> Int4,
279         mod_user_id -> Int4,
280         community_id -> Int4,
281         reason -> Nullable<Text>,
282         removed -> Nullable<Bool>,
283         expires -> Nullable<Timestamp>,
284         when_ -> Timestamp,
285     }
286 }
287
288 table! {
289     mod_remove_post (id) {
290         id -> Int4,
291         mod_user_id -> Int4,
292         post_id -> Int4,
293         reason -> Nullable<Text>,
294         removed -> Nullable<Bool>,
295         when_ -> Timestamp,
296     }
297 }
298
299 table! {
300     mod_sticky_post (id) {
301         id -> Int4,
302         mod_user_id -> Int4,
303         post_id -> Int4,
304         stickied -> Nullable<Bool>,
305         when_ -> Timestamp,
306     }
307 }
308
309 table! {
310     password_reset_request (id) {
311         id -> Int4,
312         user_id -> Int4,
313         token_encrypted -> Text,
314         published -> Timestamp,
315     }
316 }
317
318 table! {
319     post (id) {
320         id -> Int4,
321         name -> Varchar,
322         url -> Nullable<Text>,
323         body -> Nullable<Text>,
324         creator_id -> Int4,
325         community_id -> Int4,
326         removed -> Bool,
327         locked -> Bool,
328         published -> Timestamp,
329         updated -> Nullable<Timestamp>,
330         deleted -> Bool,
331         nsfw -> Bool,
332         stickied -> Bool,
333         embed_title -> Nullable<Text>,
334         embed_description -> Nullable<Text>,
335         embed_html -> Nullable<Text>,
336         thumbnail_url -> Nullable<Text>,
337         ap_id -> Varchar,
338         local -> Bool,
339     }
340 }
341
342 table! {
343     post_aggregates (id) {
344         id -> Int4,
345         post_id -> Int4,
346         comments -> Int8,
347         score -> Int8,
348         upvotes -> Int8,
349         downvotes -> Int8,
350         newest_comment_time -> Timestamp,
351     }
352 }
353
354 table! {
355     post_aggregates_fast (id) {
356         id -> Int4,
357         name -> Nullable<Varchar>,
358         url -> Nullable<Text>,
359         body -> Nullable<Text>,
360         creator_id -> Nullable<Int4>,
361         community_id -> Nullable<Int4>,
362         removed -> Nullable<Bool>,
363         locked -> Nullable<Bool>,
364         published -> Nullable<Timestamp>,
365         updated -> Nullable<Timestamp>,
366         deleted -> Nullable<Bool>,
367         nsfw -> Nullable<Bool>,
368         stickied -> Nullable<Bool>,
369         embed_title -> Nullable<Text>,
370         embed_description -> Nullable<Text>,
371         embed_html -> Nullable<Text>,
372         thumbnail_url -> Nullable<Text>,
373         ap_id -> Nullable<Varchar>,
374         local -> Nullable<Bool>,
375         creator_actor_id -> Nullable<Varchar>,
376         creator_local -> Nullable<Bool>,
377         creator_name -> Nullable<Varchar>,
378         creator_preferred_username -> Nullable<Varchar>,
379         creator_published -> Nullable<Timestamp>,
380         creator_avatar -> Nullable<Text>,
381         banned -> Nullable<Bool>,
382         banned_from_community -> Nullable<Bool>,
383         community_actor_id -> Nullable<Varchar>,
384         community_local -> Nullable<Bool>,
385         community_name -> Nullable<Varchar>,
386         community_icon -> Nullable<Text>,
387         community_removed -> Nullable<Bool>,
388         community_deleted -> Nullable<Bool>,
389         community_nsfw -> Nullable<Bool>,
390         number_of_comments -> Nullable<Int8>,
391         score -> Nullable<Int8>,
392         upvotes -> Nullable<Int8>,
393         downvotes -> Nullable<Int8>,
394         hot_rank -> Nullable<Int4>,
395         hot_rank_active -> Nullable<Int4>,
396         newest_activity_time -> Nullable<Timestamp>,
397     }
398 }
399
400 table! {
401     post_like (id) {
402         id -> Int4,
403         post_id -> Int4,
404         user_id -> Int4,
405         score -> Int2,
406         published -> Timestamp,
407     }
408 }
409
410 table! {
411     post_read (id) {
412         id -> Int4,
413         post_id -> Int4,
414         user_id -> Int4,
415         published -> Timestamp,
416     }
417 }
418
419 table! {
420     post_report (id) {
421         id -> Int4,
422         creator_id -> Int4,
423         post_id -> Int4,
424         original_post_name -> Varchar,
425         original_post_url -> Nullable<Text>,
426         original_post_body -> Nullable<Text>,
427         reason -> Text,
428         resolved -> Bool,
429         resolver_id -> Nullable<Int4>,
430         published -> Timestamp,
431         updated -> Nullable<Timestamp>,
432     }
433 }
434
435 table! {
436     post_saved (id) {
437         id -> Int4,
438         post_id -> Int4,
439         user_id -> Int4,
440         published -> Timestamp,
441     }
442 }
443
444 table! {
445     private_message (id) {
446         id -> Int4,
447         creator_id -> Int4,
448         recipient_id -> Int4,
449         content -> Text,
450         deleted -> Bool,
451         read -> Bool,
452         published -> Timestamp,
453         updated -> Nullable<Timestamp>,
454         ap_id -> Varchar,
455         local -> Bool,
456     }
457 }
458
459 table! {
460     site (id) {
461         id -> Int4,
462         name -> Varchar,
463         description -> Nullable<Text>,
464         creator_id -> Int4,
465         published -> Timestamp,
466         updated -> Nullable<Timestamp>,
467         enable_downvotes -> Bool,
468         open_registration -> Bool,
469         enable_nsfw -> Bool,
470         icon -> Nullable<Text>,
471         banner -> Nullable<Text>,
472     }
473 }
474
475 table! {
476     site_aggregates (id) {
477         id -> Int4,
478         users -> Int8,
479         posts -> Int8,
480         comments -> Int8,
481         communities -> Int8,
482     }
483 }
484
485 table! {
486     user_ (id) {
487         id -> Int4,
488         name -> Varchar,
489         preferred_username -> Nullable<Varchar>,
490         password_encrypted -> Text,
491         email -> Nullable<Text>,
492         avatar -> Nullable<Text>,
493         admin -> Bool,
494         banned -> Bool,
495         published -> Timestamp,
496         updated -> Nullable<Timestamp>,
497         show_nsfw -> Bool,
498         theme -> Varchar,
499         default_sort_type -> Int2,
500         default_listing_type -> Int2,
501         lang -> Varchar,
502         show_avatars -> Bool,
503         send_notifications_to_email -> Bool,
504         matrix_user_id -> Nullable<Text>,
505         actor_id -> Varchar,
506         bio -> Nullable<Text>,
507         local -> Bool,
508         private_key -> Nullable<Text>,
509         public_key -> Nullable<Text>,
510         last_refreshed_at -> Timestamp,
511         banner -> Nullable<Text>,
512         deleted -> Bool,
513     }
514 }
515
516 table! {
517     user_aggregates (id) {
518         id -> Int4,
519         user_id -> Int4,
520         post_count -> Int8,
521         post_score -> Int8,
522         comment_count -> Int8,
523         comment_score -> Int8,
524     }
525 }
526
527 table! {
528     user_ban (id) {
529         id -> Int4,
530         user_id -> Int4,
531         published -> Timestamp,
532     }
533 }
534
535 table! {
536     user_fast (id) {
537         id -> Int4,
538         actor_id -> Nullable<Varchar>,
539         name -> Nullable<Varchar>,
540         preferred_username -> Nullable<Varchar>,
541         avatar -> Nullable<Text>,
542         banner -> Nullable<Text>,
543         email -> Nullable<Text>,
544         matrix_user_id -> Nullable<Text>,
545         bio -> Nullable<Text>,
546         local -> Nullable<Bool>,
547         admin -> Nullable<Bool>,
548         banned -> Nullable<Bool>,
549         show_avatars -> Nullable<Bool>,
550         send_notifications_to_email -> Nullable<Bool>,
551         published -> Nullable<Timestamp>,
552         number_of_posts -> Nullable<Int8>,
553         post_score -> Nullable<Int8>,
554         number_of_comments -> Nullable<Int8>,
555         comment_score -> Nullable<Int8>,
556     }
557 }
558
559 table! {
560     user_mention (id) {
561         id -> Int4,
562         recipient_id -> Int4,
563         comment_id -> Int4,
564         read -> Bool,
565         published -> Timestamp,
566     }
567 }
568
569 // These are necessary since diesel doesn't have self joins / aliases
570 table! {
571     comment_alias_1 (id) {
572         id -> Int4,
573         creator_id -> Int4,
574         post_id -> Int4,
575         parent_id -> Nullable<Int4>,
576         content -> Text,
577         removed -> Bool,
578         read -> Bool,
579         published -> Timestamp,
580         updated -> Nullable<Timestamp>,
581         deleted -> Bool,
582         ap_id -> Varchar,
583         local -> Bool,
584     }
585 }
586
587 table! {
588     user_alias_1 (id) {
589         id -> Int4,
590         name -> Varchar,
591         preferred_username -> Nullable<Varchar>,
592         password_encrypted -> Text,
593         email -> Nullable<Text>,
594         avatar -> Nullable<Text>,
595         admin -> Bool,
596         banned -> Bool,
597         published -> Timestamp,
598         updated -> Nullable<Timestamp>,
599         show_nsfw -> Bool,
600         theme -> Varchar,
601         default_sort_type -> Int2,
602         default_listing_type -> Int2,
603         lang -> Varchar,
604         show_avatars -> Bool,
605         send_notifications_to_email -> Bool,
606         matrix_user_id -> Nullable<Text>,
607         actor_id -> Varchar,
608         bio -> Nullable<Text>,
609         local -> Bool,
610         private_key -> Nullable<Text>,
611         public_key -> Nullable<Text>,
612         last_refreshed_at -> Timestamp,
613         banner -> Nullable<Text>,
614         deleted -> Bool,
615     }
616 }
617
618 joinable!(comment_alias_1 -> user_alias_1 (creator_id));
619 joinable!(comment -> comment_alias_1 (parent_id));
620
621 joinable!(comment -> post (post_id));
622 joinable!(comment -> user_ (creator_id));
623 joinable!(comment_aggregates -> comment (comment_id));
624 joinable!(comment_like -> comment (comment_id));
625 joinable!(comment_like -> post (post_id));
626 joinable!(comment_like -> user_ (user_id));
627 joinable!(comment_report -> comment (comment_id));
628 joinable!(comment_saved -> comment (comment_id));
629 joinable!(comment_saved -> user_ (user_id));
630 joinable!(community -> category (category_id));
631 joinable!(community -> user_ (creator_id));
632 joinable!(community_aggregates -> community (community_id));
633 joinable!(community_follower -> community (community_id));
634 joinable!(community_follower -> user_ (user_id));
635 joinable!(community_moderator -> community (community_id));
636 joinable!(community_moderator -> user_ (user_id));
637 joinable!(community_user_ban -> community (community_id));
638 joinable!(community_user_ban -> user_ (user_id));
639 joinable!(mod_add_community -> community (community_id));
640 joinable!(mod_ban_from_community -> community (community_id));
641 joinable!(mod_lock_post -> post (post_id));
642 joinable!(mod_lock_post -> user_ (mod_user_id));
643 joinable!(mod_remove_comment -> comment (comment_id));
644 joinable!(mod_remove_comment -> user_ (mod_user_id));
645 joinable!(mod_remove_community -> community (community_id));
646 joinable!(mod_remove_community -> user_ (mod_user_id));
647 joinable!(mod_remove_post -> post (post_id));
648 joinable!(mod_remove_post -> user_ (mod_user_id));
649 joinable!(mod_sticky_post -> post (post_id));
650 joinable!(mod_sticky_post -> user_ (mod_user_id));
651 joinable!(password_reset_request -> user_ (user_id));
652 joinable!(post -> community (community_id));
653 joinable!(post -> user_ (creator_id));
654 joinable!(post_aggregates -> post (post_id));
655 joinable!(post_like -> post (post_id));
656 joinable!(post_like -> user_ (user_id));
657 joinable!(post_read -> post (post_id));
658 joinable!(post_read -> user_ (user_id));
659 joinable!(post_report -> post (post_id));
660 joinable!(post_saved -> post (post_id));
661 joinable!(post_saved -> user_ (user_id));
662 joinable!(site -> user_ (creator_id));
663 joinable!(user_aggregates -> user_ (user_id));
664 joinable!(user_ban -> user_ (user_id));
665 joinable!(user_mention -> comment (comment_id));
666 joinable!(user_mention -> user_ (recipient_id));
667
668 allow_tables_to_appear_in_same_query!(
669   activity,
670   category,
671   comment,
672   comment_aggregates,
673   comment_aggregates_fast,
674   comment_like,
675   comment_report,
676   comment_saved,
677   community,
678   community_aggregates,
679   community_aggregates_fast,
680   community_follower,
681   community_moderator,
682   community_user_ban,
683   mod_add,
684   mod_add_community,
685   mod_ban,
686   mod_ban_from_community,
687   mod_lock_post,
688   mod_remove_comment,
689   mod_remove_community,
690   mod_remove_post,
691   mod_sticky_post,
692   password_reset_request,
693   post,
694   post_aggregates,
695   post_aggregates_fast,
696   post_like,
697   post_read,
698   post_report,
699   post_saved,
700   private_message,
701   site,
702   site_aggregates,
703   user_,
704   user_aggregates,
705   user_ban,
706   user_fast,
707   user_mention,
708   comment_alias_1,
709   user_alias_1,
710 );