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