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