]> Untitled Git - lemmy.git/blob - crates/db_schema/src/schema.rs
fcd99c1b18a351bc1e4a855f4db9c01eb25611b1
[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         interface_language -> 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         language_id -> Int4,
379     }
380 }
381
382 table! {
383     post_aggregates (id) {
384         id -> Int4,
385         post_id -> Int4,
386         comments -> Int8,
387         score -> Int8,
388         upvotes -> Int8,
389         downvotes -> Int8,
390         stickied -> Bool,
391         published -> Timestamp,
392         newest_comment_time_necro -> Timestamp,
393         newest_comment_time -> Timestamp,
394     }
395 }
396
397 table! {
398     post_like (id) {
399         id -> Int4,
400         post_id -> Int4,
401         person_id -> Int4,
402         score -> Int2,
403         published -> Timestamp,
404     }
405 }
406
407 table! {
408     post_read (id) {
409         id -> Int4,
410         post_id -> Int4,
411         person_id -> Int4,
412         published -> Timestamp,
413     }
414 }
415
416 table! {
417     post_report (id) {
418         id -> Int4,
419         creator_id -> Int4,
420         post_id -> Int4,
421         original_post_name -> Varchar,
422         original_post_url -> Nullable<Text>,
423         original_post_body -> Nullable<Text>,
424         reason -> Text,
425         resolved -> Bool,
426         resolver_id -> Nullable<Int4>,
427         published -> Timestamp,
428         updated -> Nullable<Timestamp>,
429     }
430 }
431
432 table! {
433     post_saved (id) {
434         id -> Int4,
435         post_id -> Int4,
436         person_id -> Int4,
437         published -> Timestamp,
438     }
439 }
440
441 table! {
442     private_message (id) {
443         id -> Int4,
444         creator_id -> Int4,
445         recipient_id -> Int4,
446         content -> Text,
447         deleted -> Bool,
448         read -> Bool,
449         published -> Timestamp,
450         updated -> Nullable<Timestamp>,
451         ap_id -> Varchar,
452         local -> Bool,
453     }
454 }
455
456 table! {
457     site (id) {
458         id -> Int4,
459         name -> Varchar,
460         sidebar -> Nullable<Text>,
461         published -> Timestamp,
462         updated -> Nullable<Timestamp>,
463         enable_downvotes -> Bool,
464         open_registration -> Bool,
465         enable_nsfw -> Bool,
466         icon -> Nullable<Varchar>,
467         banner -> Nullable<Varchar>,
468         description -> Nullable<Text>,
469         community_creation_admin_only -> Bool,
470         require_email_verification -> Bool,
471         require_application -> Bool,
472         application_question -> Nullable<Text>,
473         private_instance -> Bool,
474         actor_id -> Text,
475         last_refreshed_at -> Timestamp,
476         inbox_url -> Text,
477         private_key -> Nullable<Text>,
478         public_key -> Text,
479         default_theme -> Text,
480         default_post_listing_type -> Text,
481         legal_information -> Nullable<Text>,
482         hide_modlog_mod_names -> Bool,
483     }
484 }
485
486 table! {
487     site_aggregates (id) {
488         id -> Int4,
489         site_id -> Int4,
490         users -> Int8,
491         posts -> Int8,
492         comments -> Int8,
493         communities -> Int8,
494         users_active_day -> Int8,
495         users_active_week -> Int8,
496         users_active_month -> Int8,
497         users_active_half_year -> Int8,
498     }
499 }
500
501 table! {
502     person_block (id) {
503         id -> Int4,
504         person_id -> Int4,
505         target_id -> Int4,
506         published -> Timestamp,
507     }
508 }
509
510 table! {
511     community_block (id) {
512         id -> Int4,
513         person_id -> Int4,
514         community_id -> Int4,
515         published -> Timestamp,
516     }
517 }
518
519 // These are necessary since diesel doesn't have self joins / aliases
520 table! {
521     person_alias_1 (id) {
522         id -> Int4,
523         name -> Varchar,
524         display_name -> Nullable<Varchar>,
525         avatar -> Nullable<Varchar>,
526         banned -> Bool,
527         published -> Timestamp,
528         updated -> Nullable<Timestamp>,
529         actor_id -> Varchar,
530         bio -> Nullable<Text>,
531         local -> Bool,
532         private_key -> Nullable<Text>,
533         public_key -> Text,
534         last_refreshed_at -> Timestamp,
535         banner -> Nullable<Varchar>,
536         deleted -> Bool,
537         inbox_url -> Varchar,
538         shared_inbox_url -> Nullable<Varchar>,
539         matrix_user_id -> Nullable<Text>,
540         admin -> Bool,
541         bot_account -> Bool,
542         ban_expires -> Nullable<Timestamp>,
543     }
544 }
545
546 table! {
547     person_alias_2 (id) {
548         id -> Int4,
549         name -> Varchar,
550         display_name -> Nullable<Varchar>,
551         avatar -> Nullable<Varchar>,
552         banned -> Bool,
553         published -> Timestamp,
554         updated -> Nullable<Timestamp>,
555         actor_id -> Varchar,
556         bio -> Nullable<Text>,
557         local -> Bool,
558         private_key -> Nullable<Text>,
559         public_key -> Text,
560         last_refreshed_at -> Timestamp,
561         banner -> Nullable<Varchar>,
562         deleted -> Bool,
563         inbox_url -> Varchar,
564         shared_inbox_url -> Nullable<Varchar>,
565         matrix_user_id -> Nullable<Text>,
566         admin -> Bool,
567         bot_account -> Bool,
568         ban_expires -> Nullable<Timestamp>,
569     }
570 }
571
572 table! {
573   secret(id) {
574     id -> Int4,
575     jwt_secret -> Varchar,
576   }
577 }
578
579 table! {
580   admin_purge_comment (id) {
581     id -> Int4,
582     admin_person_id -> Int4,
583     post_id -> Int4,
584     reason -> Nullable<Text>,
585     when_ -> Timestamp,
586   }
587 }
588
589 table! {
590   email_verification (id) {
591     id -> Int4,
592     local_user_id -> Int4,
593     email -> Text,
594     verification_token -> Varchar,
595     published -> Timestamp,
596   }
597 }
598
599 table! {
600   admin_purge_community (id) {
601     id -> Int4,
602     admin_person_id -> Int4,
603     reason -> Nullable<Text>,
604     when_ -> Timestamp,
605   }
606 }
607
608 table! {
609   admin_purge_person (id) {
610     id -> Int4,
611     admin_person_id -> Int4,
612     reason -> Nullable<Text>,
613     when_ -> Timestamp,
614   }
615 }
616
617 table! {
618   admin_purge_post (id) {
619     id -> Int4,
620     admin_person_id -> Int4,
621     community_id -> Int4,
622     reason -> Nullable<Text>,
623     when_ -> Timestamp,
624   }
625 }
626
627 table! {
628     registration_application (id) {
629         id -> Int4,
630         local_user_id -> Int4,
631         answer -> Text,
632         admin_id -> Nullable<Int4>,
633         deny_reason -> Nullable<Text>,
634         published -> Timestamp,
635     }
636 }
637
638 table! {
639     mod_hide_community (id) {
640         id -> Int4,
641         community_id -> Int4,
642         mod_person_id -> Int4,
643         reason -> Nullable<Text>,
644         hidden -> Nullable<Bool>,
645         when_ -> Timestamp,
646     }
647 }
648
649 table! {
650     language (id) {
651         id -> Int4,
652         code -> Text,
653         name -> Text,
654     }
655 }
656
657 table! {
658     local_user_language(id) {
659         id -> Int4,
660         local_user_id -> Int4,
661         language_id -> Int4,
662     }
663 }
664
665 joinable!(person_mention -> person_alias_1 (recipient_id));
666 joinable!(comment_reply -> person_alias_1 (recipient_id));
667 joinable!(post -> person_alias_1 (creator_id));
668 joinable!(comment -> person_alias_1 (creator_id));
669
670 joinable!(post_report -> person_alias_2 (resolver_id));
671 joinable!(comment_report -> person_alias_2 (resolver_id));
672
673 joinable!(person_block -> person (person_id));
674 joinable!(person_block -> person_alias_1 (target_id));
675
676 joinable!(comment -> person (creator_id));
677 joinable!(comment -> post (post_id));
678 joinable!(comment_aggregates -> comment (comment_id));
679 joinable!(comment_like -> comment (comment_id));
680 joinable!(comment_like -> person (person_id));
681 joinable!(comment_like -> post (post_id));
682 joinable!(comment_report -> comment (comment_id));
683 joinable!(comment_saved -> comment (comment_id));
684 joinable!(comment_saved -> person (person_id));
685 joinable!(community_aggregates -> community (community_id));
686 joinable!(community_block -> community (community_id));
687 joinable!(community_block -> person (person_id));
688 joinable!(community_follower -> community (community_id));
689 joinable!(community_follower -> person (person_id));
690 joinable!(community_moderator -> community (community_id));
691 joinable!(community_moderator -> person (person_id));
692 joinable!(community_person_ban -> community (community_id));
693 joinable!(community_person_ban -> person (person_id));
694 joinable!(local_user -> person (person_id));
695 joinable!(mod_add_community -> community (community_id));
696 joinable!(mod_transfer_community -> community (community_id));
697 joinable!(mod_ban_from_community -> community (community_id));
698 joinable!(mod_lock_post -> person (mod_person_id));
699 joinable!(mod_lock_post -> post (post_id));
700 joinable!(mod_remove_comment -> comment (comment_id));
701 joinable!(mod_remove_comment -> person (mod_person_id));
702 joinable!(mod_remove_community -> community (community_id));
703 joinable!(mod_remove_community -> person (mod_person_id));
704 joinable!(mod_remove_post -> person (mod_person_id));
705 joinable!(mod_remove_post -> post (post_id));
706 joinable!(mod_sticky_post -> person (mod_person_id));
707 joinable!(mod_sticky_post -> post (post_id));
708 joinable!(password_reset_request -> local_user (local_user_id));
709 joinable!(person_aggregates -> person (person_id));
710 joinable!(person_ban -> person (person_id));
711 joinable!(person_mention -> comment (comment_id));
712 joinable!(person_mention -> person (recipient_id));
713 joinable!(comment_reply -> comment (comment_id));
714 joinable!(comment_reply -> person (recipient_id));
715 joinable!(post -> community (community_id));
716 joinable!(post -> person (creator_id));
717 joinable!(post_aggregates -> post (post_id));
718 joinable!(post_like -> person (person_id));
719 joinable!(post_like -> post (post_id));
720 joinable!(post_read -> person (person_id));
721 joinable!(post_read -> post (post_id));
722 joinable!(post_report -> post (post_id));
723 joinable!(post_saved -> person (person_id));
724 joinable!(post_saved -> post (post_id));
725 joinable!(site_aggregates -> site (site_id));
726 joinable!(email_verification -> local_user (local_user_id));
727 joinable!(registration_application -> local_user (local_user_id));
728 joinable!(registration_application -> person (admin_id));
729 joinable!(mod_hide_community -> person (mod_person_id));
730 joinable!(mod_hide_community -> community (community_id));
731 joinable!(post -> language (language_id));
732 joinable!(local_user_language -> language (language_id));
733 joinable!(local_user_language -> local_user (local_user_id));
734
735 joinable!(admin_purge_comment -> person (admin_person_id));
736 joinable!(admin_purge_comment -> post (post_id));
737 joinable!(admin_purge_community -> person (admin_person_id));
738 joinable!(admin_purge_person -> person (admin_person_id));
739 joinable!(admin_purge_post -> community (community_id));
740 joinable!(admin_purge_post -> person (admin_person_id));
741
742 allow_tables_to_appear_in_same_query!(
743   activity,
744   comment,
745   comment_aggregates,
746   community_block,
747   comment_like,
748   comment_report,
749   comment_saved,
750   community,
751   community_aggregates,
752   community_follower,
753   community_moderator,
754   community_person_ban,
755   local_user,
756   mod_add,
757   mod_add_community,
758   mod_transfer_community,
759   mod_ban,
760   mod_ban_from_community,
761   mod_lock_post,
762   mod_remove_comment,
763   mod_remove_community,
764   mod_remove_post,
765   mod_sticky_post,
766   mod_hide_community,
767   password_reset_request,
768   person,
769   person_aggregates,
770   person_ban,
771   person_block,
772   person_mention,
773   comment_reply,
774   post,
775   post_aggregates,
776   post_like,
777   post_read,
778   post_report,
779   post_saved,
780   private_message,
781   site,
782   site_aggregates,
783   person_alias_1,
784   person_alias_2,
785   admin_purge_comment,
786   admin_purge_community,
787   admin_purge_person,
788   admin_purge_post,
789   email_verification,
790   registration_application,
791   language,
792   local_user_language
793 );