]> Untitled Git - lemmy.git/blob - crates/db_schema/src/schema.rs
Add Modlog Filters (#2313)
[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         hide_modlog_mod_names -> Bool,
481     }
482 }
483
484 table! {
485     site_aggregates (id) {
486         id -> Int4,
487         site_id -> Int4,
488         users -> Int8,
489         posts -> Int8,
490         comments -> Int8,
491         communities -> Int8,
492         users_active_day -> Int8,
493         users_active_week -> Int8,
494         users_active_month -> Int8,
495         users_active_half_year -> Int8,
496     }
497 }
498
499 table! {
500     person_block (id) {
501         id -> Int4,
502         person_id -> Int4,
503         target_id -> Int4,
504         published -> Timestamp,
505     }
506 }
507
508 table! {
509     community_block (id) {
510         id -> Int4,
511         person_id -> Int4,
512         community_id -> Int4,
513         published -> Timestamp,
514     }
515 }
516
517 // These are necessary since diesel doesn't have self joins / aliases
518 table! {
519     person_alias_1 (id) {
520         id -> Int4,
521         name -> Varchar,
522         display_name -> Nullable<Varchar>,
523         avatar -> Nullable<Varchar>,
524         banned -> Bool,
525         published -> Timestamp,
526         updated -> Nullable<Timestamp>,
527         actor_id -> Varchar,
528         bio -> Nullable<Text>,
529         local -> Bool,
530         private_key -> Nullable<Text>,
531         public_key -> Text,
532         last_refreshed_at -> Timestamp,
533         banner -> Nullable<Varchar>,
534         deleted -> Bool,
535         inbox_url -> Varchar,
536         shared_inbox_url -> Nullable<Varchar>,
537         matrix_user_id -> Nullable<Text>,
538         admin -> Bool,
539         bot_account -> Bool,
540         ban_expires -> Nullable<Timestamp>,
541     }
542 }
543
544 table! {
545     person_alias_2 (id) {
546         id -> Int4,
547         name -> Varchar,
548         display_name -> Nullable<Varchar>,
549         avatar -> Nullable<Varchar>,
550         banned -> Bool,
551         published -> Timestamp,
552         updated -> Nullable<Timestamp>,
553         actor_id -> Varchar,
554         bio -> Nullable<Text>,
555         local -> Bool,
556         private_key -> Nullable<Text>,
557         public_key -> Text,
558         last_refreshed_at -> Timestamp,
559         banner -> Nullable<Varchar>,
560         deleted -> Bool,
561         inbox_url -> Varchar,
562         shared_inbox_url -> Nullable<Varchar>,
563         matrix_user_id -> Nullable<Text>,
564         admin -> Bool,
565         bot_account -> Bool,
566         ban_expires -> Nullable<Timestamp>,
567     }
568 }
569
570 table! {
571   secret(id) {
572     id -> Int4,
573     jwt_secret -> Varchar,
574   }
575 }
576
577 table! {
578   admin_purge_comment (id) {
579     id -> Int4,
580     admin_person_id -> Int4,
581     post_id -> Int4,
582     reason -> Nullable<Text>,
583     when_ -> Timestamp,
584   }
585 }
586
587 table! {
588   email_verification (id) {
589     id -> Int4,
590     local_user_id -> Int4,
591     email -> Text,
592     verification_token -> Varchar,
593     published -> Timestamp,
594   }
595 }
596
597 table! {
598   admin_purge_community (id) {
599     id -> Int4,
600     admin_person_id -> Int4,
601     reason -> Nullable<Text>,
602     when_ -> Timestamp,
603   }
604 }
605
606 table! {
607   admin_purge_person (id) {
608     id -> Int4,
609     admin_person_id -> Int4,
610     reason -> Nullable<Text>,
611     when_ -> Timestamp,
612   }
613 }
614
615 table! {
616   admin_purge_post (id) {
617     id -> Int4,
618     admin_person_id -> Int4,
619     community_id -> Int4,
620     reason -> Nullable<Text>,
621     when_ -> Timestamp,
622   }
623 }
624
625 table! {
626     registration_application (id) {
627         id -> Int4,
628         local_user_id -> Int4,
629         answer -> Text,
630         admin_id -> Nullable<Int4>,
631         deny_reason -> Nullable<Text>,
632         published -> Timestamp,
633     }
634 }
635
636 table! {
637     mod_hide_community (id) {
638         id -> Int4,
639         community_id -> Int4,
640         mod_person_id -> Int4,
641         reason -> Nullable<Text>,
642         hidden -> Nullable<Bool>,
643         when_ -> Timestamp,
644     }
645 }
646
647 joinable!(person_mention -> person_alias_1 (recipient_id));
648 joinable!(comment_reply -> person_alias_1 (recipient_id));
649 joinable!(post -> person_alias_1 (creator_id));
650 joinable!(comment -> person_alias_1 (creator_id));
651
652 joinable!(post_report -> person_alias_2 (resolver_id));
653 joinable!(comment_report -> person_alias_2 (resolver_id));
654
655 joinable!(person_block -> person (person_id));
656 joinable!(person_block -> person_alias_1 (target_id));
657
658 joinable!(comment -> person (creator_id));
659 joinable!(comment -> post (post_id));
660 joinable!(comment_aggregates -> comment (comment_id));
661 joinable!(comment_like -> comment (comment_id));
662 joinable!(comment_like -> person (person_id));
663 joinable!(comment_like -> post (post_id));
664 joinable!(comment_report -> comment (comment_id));
665 joinable!(comment_saved -> comment (comment_id));
666 joinable!(comment_saved -> person (person_id));
667 joinable!(community_aggregates -> community (community_id));
668 joinable!(community_block -> community (community_id));
669 joinable!(community_block -> person (person_id));
670 joinable!(community_follower -> community (community_id));
671 joinable!(community_follower -> person (person_id));
672 joinable!(community_moderator -> community (community_id));
673 joinable!(community_moderator -> person (person_id));
674 joinable!(community_person_ban -> community (community_id));
675 joinable!(community_person_ban -> person (person_id));
676 joinable!(local_user -> person (person_id));
677 joinable!(mod_add_community -> community (community_id));
678 joinable!(mod_transfer_community -> community (community_id));
679 joinable!(mod_ban_from_community -> community (community_id));
680 joinable!(mod_lock_post -> person (mod_person_id));
681 joinable!(mod_lock_post -> post (post_id));
682 joinable!(mod_remove_comment -> comment (comment_id));
683 joinable!(mod_remove_comment -> person (mod_person_id));
684 joinable!(mod_remove_community -> community (community_id));
685 joinable!(mod_remove_community -> person (mod_person_id));
686 joinable!(mod_remove_post -> person (mod_person_id));
687 joinable!(mod_remove_post -> post (post_id));
688 joinable!(mod_sticky_post -> person (mod_person_id));
689 joinable!(mod_sticky_post -> post (post_id));
690 joinable!(password_reset_request -> local_user (local_user_id));
691 joinable!(person_aggregates -> person (person_id));
692 joinable!(person_ban -> person (person_id));
693 joinable!(person_mention -> comment (comment_id));
694 joinable!(person_mention -> person (recipient_id));
695 joinable!(comment_reply -> comment (comment_id));
696 joinable!(comment_reply -> person (recipient_id));
697 joinable!(post -> community (community_id));
698 joinable!(post -> person (creator_id));
699 joinable!(post_aggregates -> post (post_id));
700 joinable!(post_like -> person (person_id));
701 joinable!(post_like -> post (post_id));
702 joinable!(post_read -> person (person_id));
703 joinable!(post_read -> post (post_id));
704 joinable!(post_report -> post (post_id));
705 joinable!(post_saved -> person (person_id));
706 joinable!(post_saved -> post (post_id));
707 joinable!(site_aggregates -> site (site_id));
708 joinable!(email_verification -> local_user (local_user_id));
709 joinable!(registration_application -> local_user (local_user_id));
710 joinable!(registration_application -> person (admin_id));
711 joinable!(mod_hide_community -> person (mod_person_id));
712 joinable!(mod_hide_community -> community (community_id));
713
714 joinable!(admin_purge_comment -> person (admin_person_id));
715 joinable!(admin_purge_comment -> post (post_id));
716 joinable!(admin_purge_community -> person (admin_person_id));
717 joinable!(admin_purge_person -> person (admin_person_id));
718 joinable!(admin_purge_post -> community (community_id));
719 joinable!(admin_purge_post -> person (admin_person_id));
720
721 allow_tables_to_appear_in_same_query!(
722   activity,
723   comment,
724   comment_aggregates,
725   community_block,
726   comment_like,
727   comment_report,
728   comment_saved,
729   community,
730   community_aggregates,
731   community_follower,
732   community_moderator,
733   community_person_ban,
734   local_user,
735   mod_add,
736   mod_add_community,
737   mod_transfer_community,
738   mod_ban,
739   mod_ban_from_community,
740   mod_lock_post,
741   mod_remove_comment,
742   mod_remove_community,
743   mod_remove_post,
744   mod_sticky_post,
745   mod_hide_community,
746   password_reset_request,
747   person,
748   person_aggregates,
749   person_ban,
750   person_block,
751   person_mention,
752   comment_reply,
753   post,
754   post_aggregates,
755   post_like,
756   post_read,
757   post_report,
758   post_saved,
759   private_message,
760   site,
761   site_aggregates,
762   person_alias_1,
763   person_alias_2,
764   admin_purge_comment,
765   admin_purge_community,
766   admin_purge_person,
767   admin_purge_post,
768   email_verification,
769   registration_application
770 );