]> Untitled Git - lemmy.git/blob - crates/db_schema/src/schema.rs
4c2caaf06c738071bae18d3e1b9fb2251052edb8
[lemmy.git] / crates / db_schema / 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 -> Text,
9         sensitive -> Nullable<Bool>,
10     }
11 }
12
13 table! {
14   use diesel_ltree::sql_types::Ltree;
15   use diesel::sql_types::*;
16
17     comment (id) {
18         id -> Int4,
19         creator_id -> Int4,
20         post_id -> Int4,
21         content -> Text,
22         removed -> Bool,
23         published -> Timestamp,
24         updated -> Nullable<Timestamp>,
25         deleted -> Bool,
26         ap_id -> Varchar,
27         local -> Bool,
28         path -> Ltree,
29         distinguished -> Bool,
30     }
31 }
32
33 table! {
34     comment_aggregates (id) {
35         id -> Int4,
36         comment_id -> Int4,
37         score -> Int8,
38         upvotes -> Int8,
39         downvotes -> Int8,
40         published -> Timestamp,
41         child_count ->  Int4,
42     }
43 }
44
45 table! {
46     comment_like (id) {
47         id -> Int4,
48         person_id -> Int4,
49         comment_id -> Int4,
50         post_id -> Int4,
51         score -> Int2,
52         published -> Timestamp,
53     }
54 }
55
56 table! {
57     comment_report (id) {
58         id -> Int4,
59         creator_id -> Int4,
60         comment_id -> Int4,
61         original_comment_text -> Text,
62         reason -> Text,
63         resolved -> Bool,
64         resolver_id -> Nullable<Int4>,
65         published -> Timestamp,
66         updated -> Nullable<Timestamp>,
67     }
68 }
69
70 table! {
71     comment_saved (id) {
72         id -> Int4,
73         comment_id -> Int4,
74         person_id -> Int4,
75         published -> Timestamp,
76     }
77 }
78
79 table! {
80     community (id) {
81         id -> Int4,
82         name -> Varchar,
83         title -> Varchar,
84         description -> Nullable<Text>,
85         removed -> Bool,
86         published -> Timestamp,
87         updated -> Nullable<Timestamp>,
88         deleted -> Bool,
89         nsfw -> Bool,
90         actor_id -> Varchar,
91         local -> Bool,
92         private_key -> Nullable<Text>,
93         public_key -> Text,
94         last_refreshed_at -> Timestamp,
95         icon -> Nullable<Varchar>,
96         banner -> Nullable<Varchar>,
97         followers_url -> Varchar,
98         inbox_url -> Varchar,
99         shared_inbox_url -> Nullable<Varchar>,
100         hidden -> Bool,
101         posting_restricted_to_mods -> Bool,
102     }
103 }
104
105 table! {
106     community_aggregates (id) {
107         id -> Int4,
108         community_id -> Int4,
109         subscribers -> Int8,
110         posts -> Int8,
111         comments -> Int8,
112         published -> Timestamp,
113         users_active_day -> Int8,
114         users_active_week -> Int8,
115         users_active_month -> Int8,
116         users_active_half_year -> Int8,
117     }
118 }
119
120 table! {
121     community_follower (id) {
122         id -> Int4,
123         community_id -> Int4,
124         person_id -> Int4,
125         published -> Timestamp,
126         pending -> Nullable<Bool>,
127     }
128 }
129
130 table! {
131     community_moderator (id) {
132         id -> Int4,
133         community_id -> Int4,
134         person_id -> Int4,
135         published -> Timestamp,
136     }
137 }
138
139 table! {
140     community_person_ban (id) {
141         id -> Int4,
142         community_id -> Int4,
143         person_id -> Int4,
144         published -> Timestamp,
145         expires -> Nullable<Timestamp>,
146     }
147 }
148
149 table! {
150     local_user (id) {
151         id -> Int4,
152         person_id -> Int4,
153         password_encrypted -> Text,
154         email -> Nullable<Text>,
155         show_nsfw -> Bool,
156         theme -> Varchar,
157         default_sort_type -> Int2,
158         default_listing_type -> Int2,
159         lang -> Varchar,
160         show_avatars -> Bool,
161         send_notifications_to_email -> Bool,
162         validator_time -> Timestamp,
163         show_bot_accounts -> Bool,
164         show_scores -> Bool,
165         show_read_posts -> Bool,
166         show_new_post_notifs -> Bool,
167         email_verified -> Bool,
168         accepted_application -> Bool,
169     }
170 }
171
172 table! {
173     mod_add (id) {
174         id -> Int4,
175         mod_person_id -> Int4,
176         other_person_id -> Int4,
177         removed -> Nullable<Bool>,
178         when_ -> Timestamp,
179     }
180 }
181
182 table! {
183     mod_add_community (id) {
184         id -> Int4,
185         mod_person_id -> Int4,
186         other_person_id -> Int4,
187         community_id -> Int4,
188         removed -> Nullable<Bool>,
189         when_ -> Timestamp,
190     }
191 }
192
193 table! {
194     mod_transfer_community (id) {
195         id -> Int4,
196         mod_person_id -> Int4,
197         other_person_id -> Int4,
198         community_id -> Int4,
199         removed -> Nullable<Bool>,
200         when_ -> Timestamp,
201     }
202 }
203
204 table! {
205     mod_ban (id) {
206         id -> Int4,
207         mod_person_id -> Int4,
208         other_person_id -> Int4,
209         reason -> Nullable<Text>,
210         banned -> Nullable<Bool>,
211         expires -> Nullable<Timestamp>,
212         when_ -> Timestamp,
213     }
214 }
215
216 table! {
217     mod_ban_from_community (id) {
218         id -> Int4,
219         mod_person_id -> Int4,
220         other_person_id -> Int4,
221         community_id -> Int4,
222         reason -> Nullable<Text>,
223         banned -> Nullable<Bool>,
224         expires -> Nullable<Timestamp>,
225         when_ -> Timestamp,
226     }
227 }
228
229 table! {
230     mod_lock_post (id) {
231         id -> Int4,
232         mod_person_id -> Int4,
233         post_id -> Int4,
234         locked -> Nullable<Bool>,
235         when_ -> Timestamp,
236     }
237 }
238
239 table! {
240     mod_remove_comment (id) {
241         id -> Int4,
242         mod_person_id -> Int4,
243         comment_id -> Int4,
244         reason -> Nullable<Text>,
245         removed -> Nullable<Bool>,
246         when_ -> Timestamp,
247     }
248 }
249
250 table! {
251     mod_remove_community (id) {
252         id -> Int4,
253         mod_person_id -> Int4,
254         community_id -> Int4,
255         reason -> Nullable<Text>,
256         removed -> Nullable<Bool>,
257         expires -> Nullable<Timestamp>,
258         when_ -> Timestamp,
259     }
260 }
261
262 table! {
263     mod_remove_post (id) {
264         id -> Int4,
265         mod_person_id -> Int4,
266         post_id -> Int4,
267         reason -> Nullable<Text>,
268         removed -> Nullable<Bool>,
269         when_ -> Timestamp,
270     }
271 }
272
273 table! {
274     mod_sticky_post (id) {
275         id -> Int4,
276         mod_person_id -> Int4,
277         post_id -> Int4,
278         stickied -> Nullable<Bool>,
279         when_ -> Timestamp,
280     }
281 }
282
283 table! {
284     password_reset_request (id) {
285         id -> Int4,
286         token_encrypted -> Text,
287         published -> Timestamp,
288         local_user_id -> Int4,
289     }
290 }
291
292 table! {
293     person (id) {
294         id -> Int4,
295         name -> Varchar,
296         display_name -> Nullable<Varchar>,
297         avatar -> Nullable<Varchar>,
298         banned -> Bool,
299         published -> Timestamp,
300         updated -> Nullable<Timestamp>,
301         actor_id -> Varchar,
302         bio -> Nullable<Text>,
303         local -> Bool,
304         private_key -> Nullable<Text>,
305         public_key -> Text,
306         last_refreshed_at -> Timestamp,
307         banner -> Nullable<Varchar>,
308         deleted -> Bool,
309         inbox_url -> Varchar,
310         shared_inbox_url -> Nullable<Varchar>,
311         matrix_user_id -> Nullable<Text>,
312         admin -> Bool,
313         bot_account -> Bool,
314         ban_expires -> Nullable<Timestamp>,
315     }
316 }
317
318 table! {
319     person_aggregates (id) {
320         id -> Int4,
321         person_id -> Int4,
322         post_count -> Int8,
323         post_score -> Int8,
324         comment_count -> Int8,
325         comment_score -> Int8,
326     }
327 }
328
329 table! {
330     person_ban (id) {
331         id -> Int4,
332         person_id -> Int4,
333         published -> Timestamp,
334     }
335 }
336
337 table! {
338     person_mention (id) {
339         id -> Int4,
340         recipient_id -> Int4,
341         comment_id -> Int4,
342         read -> Bool,
343         published -> Timestamp,
344     }
345 }
346
347 table! {
348     comment_reply (id) {
349         id -> Int4,
350         recipient_id -> Int4,
351         comment_id -> Int4,
352         read -> Bool,
353         published -> Timestamp,
354     }
355 }
356
357 table! {
358     post (id) {
359         id -> Int4,
360         name -> Varchar,
361         url -> Nullable<Varchar>,
362         body -> Nullable<Text>,
363         creator_id -> Int4,
364         community_id -> Int4,
365         removed -> Bool,
366         locked -> Bool,
367         published -> Timestamp,
368         updated -> Nullable<Timestamp>,
369         deleted -> Bool,
370         nsfw -> Bool,
371         stickied -> Bool,
372         embed_title -> Nullable<Text>,
373         embed_description -> Nullable<Text>,
374         embed_video_url -> Nullable<Text>,
375         thumbnail_url -> Nullable<Text>,
376         ap_id -> Varchar,
377         local -> Bool,
378     }
379 }
380
381 table! {
382     post_aggregates (id) {
383         id -> Int4,
384         post_id -> Int4,
385         comments -> Int8,
386         score -> Int8,
387         upvotes -> Int8,
388         downvotes -> Int8,
389         stickied -> Bool,
390         published -> Timestamp,
391         newest_comment_time_necro -> Timestamp,
392         newest_comment_time -> Timestamp,
393     }
394 }
395
396 table! {
397     post_like (id) {
398         id -> Int4,
399         post_id -> Int4,
400         person_id -> Int4,
401         score -> Int2,
402         published -> Timestamp,
403     }
404 }
405
406 table! {
407     post_read (id) {
408         id -> Int4,
409         post_id -> Int4,
410         person_id -> Int4,
411         published -> Timestamp,
412     }
413 }
414
415 table! {
416     post_report (id) {
417         id -> Int4,
418         creator_id -> Int4,
419         post_id -> Int4,
420         original_post_name -> Varchar,
421         original_post_url -> Nullable<Text>,
422         original_post_body -> Nullable<Text>,
423         reason -> Text,
424         resolved -> Bool,
425         resolver_id -> Nullable<Int4>,
426         published -> Timestamp,
427         updated -> Nullable<Timestamp>,
428     }
429 }
430
431 table! {
432     post_saved (id) {
433         id -> Int4,
434         post_id -> Int4,
435         person_id -> Int4,
436         published -> Timestamp,
437     }
438 }
439
440 table! {
441     private_message (id) {
442         id -> Int4,
443         creator_id -> Int4,
444         recipient_id -> Int4,
445         content -> Text,
446         deleted -> Bool,
447         read -> Bool,
448         published -> Timestamp,
449         updated -> Nullable<Timestamp>,
450         ap_id -> Varchar,
451         local -> Bool,
452     }
453 }
454
455 table! {
456     site (id) {
457         id -> Int4,
458         name -> Varchar,
459         sidebar -> Nullable<Text>,
460         published -> Timestamp,
461         updated -> Nullable<Timestamp>,
462         enable_downvotes -> Bool,
463         open_registration -> Bool,
464         enable_nsfw -> Bool,
465         icon -> Nullable<Varchar>,
466         banner -> Nullable<Varchar>,
467         description -> Nullable<Text>,
468         community_creation_admin_only -> Bool,
469         require_email_verification -> Bool,
470         require_application -> Bool,
471         application_question -> Nullable<Text>,
472         private_instance -> Bool,
473         actor_id -> Text,
474         last_refreshed_at -> Timestamp,
475         inbox_url -> Text,
476         private_key -> Nullable<Text>,
477         public_key -> Text,
478         default_theme -> Text,
479         default_post_listing_type -> Text,
480         legal_information -> Nullable<Text>,
481         hide_modlog_mod_names -> Bool,
482     }
483 }
484
485 table! {
486     site_aggregates (id) {
487         id -> Int4,
488         site_id -> Int4,
489         users -> Int8,
490         posts -> Int8,
491         comments -> Int8,
492         communities -> Int8,
493         users_active_day -> Int8,
494         users_active_week -> Int8,
495         users_active_month -> Int8,
496         users_active_half_year -> Int8,
497     }
498 }
499
500 table! {
501     person_block (id) {
502         id -> Int4,
503         person_id -> Int4,
504         target_id -> Int4,
505         published -> Timestamp,
506     }
507 }
508
509 table! {
510     community_block (id) {
511         id -> Int4,
512         person_id -> Int4,
513         community_id -> Int4,
514         published -> Timestamp,
515     }
516 }
517
518 // These are necessary since diesel doesn't have self joins / aliases
519 table! {
520     person_alias_1 (id) {
521         id -> Int4,
522         name -> Varchar,
523         display_name -> Nullable<Varchar>,
524         avatar -> Nullable<Varchar>,
525         banned -> Bool,
526         published -> Timestamp,
527         updated -> Nullable<Timestamp>,
528         actor_id -> Varchar,
529         bio -> Nullable<Text>,
530         local -> Bool,
531         private_key -> Nullable<Text>,
532         public_key -> Text,
533         last_refreshed_at -> Timestamp,
534         banner -> Nullable<Varchar>,
535         deleted -> Bool,
536         inbox_url -> Varchar,
537         shared_inbox_url -> Nullable<Varchar>,
538         matrix_user_id -> Nullable<Text>,
539         admin -> Bool,
540         bot_account -> Bool,
541         ban_expires -> Nullable<Timestamp>,
542     }
543 }
544
545 table! {
546     person_alias_2 (id) {
547         id -> Int4,
548         name -> Varchar,
549         display_name -> Nullable<Varchar>,
550         avatar -> Nullable<Varchar>,
551         banned -> Bool,
552         published -> Timestamp,
553         updated -> Nullable<Timestamp>,
554         actor_id -> Varchar,
555         bio -> Nullable<Text>,
556         local -> Bool,
557         private_key -> Nullable<Text>,
558         public_key -> Text,
559         last_refreshed_at -> Timestamp,
560         banner -> Nullable<Varchar>,
561         deleted -> Bool,
562         inbox_url -> Varchar,
563         shared_inbox_url -> Nullable<Varchar>,
564         matrix_user_id -> Nullable<Text>,
565         admin -> Bool,
566         bot_account -> Bool,
567         ban_expires -> Nullable<Timestamp>,
568     }
569 }
570
571 table! {
572   secret(id) {
573     id -> Int4,
574     jwt_secret -> Varchar,
575   }
576 }
577
578 table! {
579   admin_purge_comment (id) {
580     id -> Int4,
581     admin_person_id -> Int4,
582     post_id -> Int4,
583     reason -> Nullable<Text>,
584     when_ -> Timestamp,
585   }
586 }
587
588 table! {
589   email_verification (id) {
590     id -> Int4,
591     local_user_id -> Int4,
592     email -> Text,
593     verification_token -> Varchar,
594     published -> Timestamp,
595   }
596 }
597
598 table! {
599   admin_purge_community (id) {
600     id -> Int4,
601     admin_person_id -> Int4,
602     reason -> Nullable<Text>,
603     when_ -> Timestamp,
604   }
605 }
606
607 table! {
608   admin_purge_person (id) {
609     id -> Int4,
610     admin_person_id -> Int4,
611     reason -> Nullable<Text>,
612     when_ -> Timestamp,
613   }
614 }
615
616 table! {
617   admin_purge_post (id) {
618     id -> Int4,
619     admin_person_id -> Int4,
620     community_id -> Int4,
621     reason -> Nullable<Text>,
622     when_ -> Timestamp,
623   }
624 }
625
626 table! {
627     registration_application (id) {
628         id -> Int4,
629         local_user_id -> Int4,
630         answer -> Text,
631         admin_id -> Nullable<Int4>,
632         deny_reason -> Nullable<Text>,
633         published -> Timestamp,
634     }
635 }
636
637 table! {
638     mod_hide_community (id) {
639         id -> Int4,
640         community_id -> Int4,
641         mod_person_id -> Int4,
642         reason -> Nullable<Text>,
643         hidden -> Nullable<Bool>,
644         when_ -> Timestamp,
645     }
646 }
647
648 joinable!(person_mention -> person_alias_1 (recipient_id));
649 joinable!(comment_reply -> person_alias_1 (recipient_id));
650 joinable!(post -> person_alias_1 (creator_id));
651 joinable!(comment -> person_alias_1 (creator_id));
652
653 joinable!(post_report -> person_alias_2 (resolver_id));
654 joinable!(comment_report -> person_alias_2 (resolver_id));
655
656 joinable!(person_block -> person (person_id));
657 joinable!(person_block -> person_alias_1 (target_id));
658
659 joinable!(comment -> person (creator_id));
660 joinable!(comment -> post (post_id));
661 joinable!(comment_aggregates -> comment (comment_id));
662 joinable!(comment_like -> comment (comment_id));
663 joinable!(comment_like -> person (person_id));
664 joinable!(comment_like -> post (post_id));
665 joinable!(comment_report -> comment (comment_id));
666 joinable!(comment_saved -> comment (comment_id));
667 joinable!(comment_saved -> person (person_id));
668 joinable!(community_aggregates -> community (community_id));
669 joinable!(community_block -> community (community_id));
670 joinable!(community_block -> person (person_id));
671 joinable!(community_follower -> community (community_id));
672 joinable!(community_follower -> person (person_id));
673 joinable!(community_moderator -> community (community_id));
674 joinable!(community_moderator -> person (person_id));
675 joinable!(community_person_ban -> community (community_id));
676 joinable!(community_person_ban -> person (person_id));
677 joinable!(local_user -> person (person_id));
678 joinable!(mod_add_community -> community (community_id));
679 joinable!(mod_transfer_community -> community (community_id));
680 joinable!(mod_ban_from_community -> community (community_id));
681 joinable!(mod_lock_post -> person (mod_person_id));
682 joinable!(mod_lock_post -> post (post_id));
683 joinable!(mod_remove_comment -> comment (comment_id));
684 joinable!(mod_remove_comment -> person (mod_person_id));
685 joinable!(mod_remove_community -> community (community_id));
686 joinable!(mod_remove_community -> person (mod_person_id));
687 joinable!(mod_remove_post -> person (mod_person_id));
688 joinable!(mod_remove_post -> post (post_id));
689 joinable!(mod_sticky_post -> person (mod_person_id));
690 joinable!(mod_sticky_post -> post (post_id));
691 joinable!(password_reset_request -> local_user (local_user_id));
692 joinable!(person_aggregates -> person (person_id));
693 joinable!(person_ban -> person (person_id));
694 joinable!(person_mention -> comment (comment_id));
695 joinable!(person_mention -> person (recipient_id));
696 joinable!(comment_reply -> comment (comment_id));
697 joinable!(comment_reply -> person (recipient_id));
698 joinable!(post -> community (community_id));
699 joinable!(post -> person (creator_id));
700 joinable!(post_aggregates -> post (post_id));
701 joinable!(post_like -> person (person_id));
702 joinable!(post_like -> post (post_id));
703 joinable!(post_read -> person (person_id));
704 joinable!(post_read -> post (post_id));
705 joinable!(post_report -> post (post_id));
706 joinable!(post_saved -> person (person_id));
707 joinable!(post_saved -> post (post_id));
708 joinable!(site_aggregates -> site (site_id));
709 joinable!(email_verification -> local_user (local_user_id));
710 joinable!(registration_application -> local_user (local_user_id));
711 joinable!(registration_application -> person (admin_id));
712 joinable!(mod_hide_community -> person (mod_person_id));
713 joinable!(mod_hide_community -> community (community_id));
714
715 joinable!(admin_purge_comment -> person (admin_person_id));
716 joinable!(admin_purge_comment -> post (post_id));
717 joinable!(admin_purge_community -> person (admin_person_id));
718 joinable!(admin_purge_person -> person (admin_person_id));
719 joinable!(admin_purge_post -> community (community_id));
720 joinable!(admin_purge_post -> person (admin_person_id));
721
722 allow_tables_to_appear_in_same_query!(
723   activity,
724   comment,
725   comment_aggregates,
726   community_block,
727   comment_like,
728   comment_report,
729   comment_saved,
730   community,
731   community_aggregates,
732   community_follower,
733   community_moderator,
734   community_person_ban,
735   local_user,
736   mod_add,
737   mod_add_community,
738   mod_transfer_community,
739   mod_ban,
740   mod_ban_from_community,
741   mod_lock_post,
742   mod_remove_comment,
743   mod_remove_community,
744   mod_remove_post,
745   mod_sticky_post,
746   mod_hide_community,
747   password_reset_request,
748   person,
749   person_aggregates,
750   person_ban,
751   person_block,
752   person_mention,
753   comment_reply,
754   post,
755   post_aggregates,
756   post_like,
757   post_read,
758   post_report,
759   post_saved,
760   private_message,
761   site,
762   site_aggregates,
763   person_alias_1,
764   person_alias_2,
765   admin_purge_comment,
766   admin_purge_community,
767   admin_purge_person,
768   admin_purge_post,
769   email_verification,
770   registration_application
771 );