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