]> Untitled Git - lemmy.git/blob - crates/db_schema/src/schema.rs
c01114d9eb6e19a549fb19e22057dbfcc559c641
[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     }
97 }
98
99 table! {
100     community_aggregates (id) {
101         id -> Int4,
102         community_id -> Int4,
103         subscribers -> Int8,
104         posts -> Int8,
105         comments -> Int8,
106         published -> Timestamp,
107         users_active_day -> Int8,
108         users_active_week -> Int8,
109         users_active_month -> Int8,
110         users_active_half_year -> Int8,
111     }
112 }
113
114 table! {
115     community_follower (id) {
116         id -> Int4,
117         community_id -> Int4,
118         person_id -> Int4,
119         published -> Timestamp,
120         pending -> Nullable<Bool>,
121     }
122 }
123
124 table! {
125     community_moderator (id) {
126         id -> Int4,
127         community_id -> Int4,
128         person_id -> Int4,
129         published -> Timestamp,
130     }
131 }
132
133 table! {
134     community_person_ban (id) {
135         id -> Int4,
136         community_id -> Int4,
137         person_id -> Int4,
138         published -> Timestamp,
139         expires -> Nullable<Timestamp>,
140     }
141 }
142
143 table! {
144     local_user (id) {
145         id -> Int4,
146         person_id -> Int4,
147         password_encrypted -> Text,
148         email -> Nullable<Text>,
149         show_nsfw -> Bool,
150         theme -> Varchar,
151         default_sort_type -> Int2,
152         default_listing_type -> Int2,
153         lang -> Varchar,
154         show_avatars -> Bool,
155         send_notifications_to_email -> Bool,
156         validator_time -> Timestamp,
157         show_bot_accounts -> Bool,
158         show_scores -> Bool,
159         show_read_posts -> Bool,
160         show_new_post_notifs -> Bool,
161         email_verified -> Bool,
162         accepted_application -> Bool,
163     }
164 }
165
166 table! {
167     mod_add (id) {
168         id -> Int4,
169         mod_person_id -> Int4,
170         other_person_id -> Int4,
171         removed -> Nullable<Bool>,
172         when_ -> Timestamp,
173     }
174 }
175
176 table! {
177     mod_add_community (id) {
178         id -> Int4,
179         mod_person_id -> Int4,
180         other_person_id -> Int4,
181         community_id -> Int4,
182         removed -> Nullable<Bool>,
183         when_ -> Timestamp,
184     }
185 }
186
187 table! {
188     mod_transfer_community (id) {
189         id -> Int4,
190         mod_person_id -> Int4,
191         other_person_id -> Int4,
192         community_id -> Int4,
193         removed -> Nullable<Bool>,
194         when_ -> Timestamp,
195     }
196 }
197
198 table! {
199     mod_ban (id) {
200         id -> Int4,
201         mod_person_id -> Int4,
202         other_person_id -> Int4,
203         reason -> Nullable<Text>,
204         banned -> Nullable<Bool>,
205         expires -> Nullable<Timestamp>,
206         when_ -> Timestamp,
207     }
208 }
209
210 table! {
211     mod_ban_from_community (id) {
212         id -> Int4,
213         mod_person_id -> Int4,
214         other_person_id -> Int4,
215         community_id -> Int4,
216         reason -> Nullable<Text>,
217         banned -> Nullable<Bool>,
218         expires -> Nullable<Timestamp>,
219         when_ -> Timestamp,
220     }
221 }
222
223 table! {
224     mod_lock_post (id) {
225         id -> Int4,
226         mod_person_id -> Int4,
227         post_id -> Int4,
228         locked -> Nullable<Bool>,
229         when_ -> Timestamp,
230     }
231 }
232
233 table! {
234     mod_remove_comment (id) {
235         id -> Int4,
236         mod_person_id -> Int4,
237         comment_id -> Int4,
238         reason -> Nullable<Text>,
239         removed -> Nullable<Bool>,
240         when_ -> Timestamp,
241     }
242 }
243
244 table! {
245     mod_remove_community (id) {
246         id -> Int4,
247         mod_person_id -> Int4,
248         community_id -> Int4,
249         reason -> Nullable<Text>,
250         removed -> Nullable<Bool>,
251         expires -> Nullable<Timestamp>,
252         when_ -> Timestamp,
253     }
254 }
255
256 table! {
257     mod_remove_post (id) {
258         id -> Int4,
259         mod_person_id -> Int4,
260         post_id -> Int4,
261         reason -> Nullable<Text>,
262         removed -> Nullable<Bool>,
263         when_ -> Timestamp,
264     }
265 }
266
267 table! {
268     mod_sticky_post (id) {
269         id -> Int4,
270         mod_person_id -> Int4,
271         post_id -> Int4,
272         stickied -> Nullable<Bool>,
273         when_ -> Timestamp,
274     }
275 }
276
277 table! {
278     password_reset_request (id) {
279         id -> Int4,
280         token_encrypted -> Text,
281         published -> Timestamp,
282         local_user_id -> Int4,
283     }
284 }
285
286 table! {
287     person (id) {
288         id -> Int4,
289         name -> Varchar,
290         display_name -> Nullable<Varchar>,
291         avatar -> Nullable<Varchar>,
292         banned -> Bool,
293         published -> Timestamp,
294         updated -> Nullable<Timestamp>,
295         actor_id -> Varchar,
296         bio -> Nullable<Text>,
297         local -> Bool,
298         private_key -> Nullable<Text>,
299         public_key -> Text,
300         last_refreshed_at -> Timestamp,
301         banner -> Nullable<Varchar>,
302         deleted -> Bool,
303         inbox_url -> Varchar,
304         shared_inbox_url -> Nullable<Varchar>,
305         matrix_user_id -> Nullable<Text>,
306         admin -> Bool,
307         bot_account -> Bool,
308         ban_expires -> Nullable<Timestamp>,
309     }
310 }
311
312 table! {
313     person_aggregates (id) {
314         id -> Int4,
315         person_id -> Int4,
316         post_count -> Int8,
317         post_score -> Int8,
318         comment_count -> Int8,
319         comment_score -> Int8,
320     }
321 }
322
323 table! {
324     person_ban (id) {
325         id -> Int4,
326         person_id -> Int4,
327         published -> Timestamp,
328     }
329 }
330
331 table! {
332     person_mention (id) {
333         id -> Int4,
334         recipient_id -> Int4,
335         comment_id -> Int4,
336         read -> Bool,
337         published -> Timestamp,
338     }
339 }
340
341 table! {
342     post (id) {
343         id -> Int4,
344         name -> Varchar,
345         url -> Nullable<Varchar>,
346         body -> Nullable<Text>,
347         creator_id -> Int4,
348         community_id -> Int4,
349         removed -> Bool,
350         locked -> Bool,
351         published -> Timestamp,
352         updated -> Nullable<Timestamp>,
353         deleted -> Bool,
354         nsfw -> Bool,
355         stickied -> Bool,
356         embed_title -> Nullable<Text>,
357         embed_description -> Nullable<Text>,
358         embed_html -> Nullable<Text>,
359         thumbnail_url -> Nullable<Text>,
360         ap_id -> Varchar,
361         local -> Bool,
362     }
363 }
364
365 table! {
366     post_aggregates (id) {
367         id -> Int4,
368         post_id -> Int4,
369         comments -> Int8,
370         score -> Int8,
371         upvotes -> Int8,
372         downvotes -> Int8,
373         stickied -> Bool,
374         published -> Timestamp,
375         newest_comment_time_necro -> Timestamp,
376         newest_comment_time -> Timestamp,
377     }
378 }
379
380 table! {
381     post_like (id) {
382         id -> Int4,
383         post_id -> Int4,
384         person_id -> Int4,
385         score -> Int2,
386         published -> Timestamp,
387     }
388 }
389
390 table! {
391     post_read (id) {
392         id -> Int4,
393         post_id -> Int4,
394         person_id -> Int4,
395         published -> Timestamp,
396     }
397 }
398
399 table! {
400     post_report (id) {
401         id -> Int4,
402         creator_id -> Int4,
403         post_id -> Int4,
404         original_post_name -> Varchar,
405         original_post_url -> Nullable<Text>,
406         original_post_body -> Nullable<Text>,
407         reason -> Text,
408         resolved -> Bool,
409         resolver_id -> Nullable<Int4>,
410         published -> Timestamp,
411         updated -> Nullable<Timestamp>,
412     }
413 }
414
415 table! {
416     post_saved (id) {
417         id -> Int4,
418         post_id -> Int4,
419         person_id -> Int4,
420         published -> Timestamp,
421     }
422 }
423
424 table! {
425     private_message (id) {
426         id -> Int4,
427         creator_id -> Int4,
428         recipient_id -> Int4,
429         content -> Text,
430         deleted -> Bool,
431         read -> Bool,
432         published -> Timestamp,
433         updated -> Nullable<Timestamp>,
434         ap_id -> Varchar,
435         local -> Bool,
436     }
437 }
438
439 table! {
440     site (id) {
441         id -> Int4,
442         name -> Varchar,
443         sidebar -> Nullable<Text>,
444         creator_id -> Int4,
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     }
459 }
460
461 table! {
462     site_aggregates (id) {
463         id -> Int4,
464         site_id -> Int4,
465         users -> Int8,
466         posts -> Int8,
467         comments -> Int8,
468         communities -> Int8,
469         users_active_day -> Int8,
470         users_active_week -> Int8,
471         users_active_month -> Int8,
472         users_active_half_year -> Int8,
473     }
474 }
475
476 table! {
477     person_block (id) {
478         id -> Int4,
479         person_id -> Int4,
480         target_id -> Int4,
481         published -> Timestamp,
482     }
483 }
484
485 table! {
486     community_block (id) {
487         id -> Int4,
488         person_id -> Int4,
489         community_id -> Int4,
490         published -> Timestamp,
491     }
492 }
493
494 // These are necessary since diesel doesn't have self joins / aliases
495 table! {
496     comment_alias_1 (id) {
497         id -> Int4,
498         creator_id -> Int4,
499         post_id -> Int4,
500         parent_id -> Nullable<Int4>,
501         content -> Text,
502         removed -> Bool,
503         read -> Bool,
504         published -> Timestamp,
505         updated -> Nullable<Timestamp>,
506         deleted -> Bool,
507         ap_id -> Varchar,
508         local -> Bool,
509     }
510 }
511
512 table! {
513     person_alias_1 (id) {
514         id -> Int4,
515         name -> Varchar,
516         display_name -> Nullable<Varchar>,
517         avatar -> Nullable<Varchar>,
518         banned -> Bool,
519         published -> Timestamp,
520         updated -> Nullable<Timestamp>,
521         actor_id -> Varchar,
522         bio -> Nullable<Text>,
523         local -> Bool,
524         private_key -> Nullable<Text>,
525         public_key -> Text,
526         last_refreshed_at -> Timestamp,
527         banner -> Nullable<Varchar>,
528         deleted -> Bool,
529         inbox_url -> Varchar,
530         shared_inbox_url -> Nullable<Varchar>,
531         matrix_user_id -> Nullable<Text>,
532         admin -> Bool,
533         bot_account -> Bool,
534         ban_expires -> Nullable<Timestamp>,
535     }
536 }
537
538 table! {
539     person_alias_2 (id) {
540         id -> Int4,
541         name -> Varchar,
542         display_name -> Nullable<Varchar>,
543         avatar -> Nullable<Varchar>,
544         banned -> Bool,
545         published -> Timestamp,
546         updated -> Nullable<Timestamp>,
547         actor_id -> Varchar,
548         bio -> Nullable<Text>,
549         local -> Bool,
550         private_key -> Nullable<Text>,
551         public_key -> Text,
552         last_refreshed_at -> Timestamp,
553         banner -> Nullable<Varchar>,
554         deleted -> Bool,
555         inbox_url -> Varchar,
556         shared_inbox_url -> Nullable<Varchar>,
557         matrix_user_id -> Nullable<Text>,
558         admin -> Bool,
559         bot_account -> Bool,
560         ban_expires -> Nullable<Timestamp>,
561     }
562 }
563
564 table! {
565   secret(id) {
566     id -> Int4,
567     jwt_secret -> Varchar,
568   }
569 }
570
571 table! {
572   email_verification (id) {
573     id -> Int4,
574     local_user_id -> Int4,
575     email -> Text,
576     verification_token -> Varchar,
577     published -> Timestamp,
578   }
579 }
580
581 table! {
582     registration_application (id) {
583         id -> Int4,
584         local_user_id -> Int4,
585         answer -> Text,
586         admin_id -> Nullable<Int4>,
587         deny_reason -> Nullable<Text>,
588         published -> Timestamp,
589     }
590 }
591
592 joinable!(comment_alias_1 -> person_alias_1 (creator_id));
593 joinable!(comment -> comment_alias_1 (parent_id));
594 joinable!(person_mention -> person_alias_1 (recipient_id));
595 joinable!(post -> person_alias_1 (creator_id));
596 joinable!(comment -> person_alias_1 (creator_id));
597
598 joinable!(post_report -> person_alias_2 (resolver_id));
599 joinable!(comment_report -> person_alias_2 (resolver_id));
600
601 joinable!(person_block -> person (person_id));
602 joinable!(person_block -> person_alias_1 (target_id));
603
604 joinable!(comment -> person (creator_id));
605 joinable!(comment -> post (post_id));
606 joinable!(comment_aggregates -> comment (comment_id));
607 joinable!(comment_like -> comment (comment_id));
608 joinable!(comment_like -> person (person_id));
609 joinable!(comment_like -> post (post_id));
610 joinable!(comment_report -> comment (comment_id));
611 joinable!(comment_saved -> comment (comment_id));
612 joinable!(comment_saved -> person (person_id));
613 joinable!(community_aggregates -> community (community_id));
614 joinable!(community_block -> community (community_id));
615 joinable!(community_block -> person (person_id));
616 joinable!(community_follower -> community (community_id));
617 joinable!(community_follower -> person (person_id));
618 joinable!(community_moderator -> community (community_id));
619 joinable!(community_moderator -> person (person_id));
620 joinable!(community_person_ban -> community (community_id));
621 joinable!(community_person_ban -> person (person_id));
622 joinable!(local_user -> person (person_id));
623 joinable!(mod_add_community -> community (community_id));
624 joinable!(mod_transfer_community -> community (community_id));
625 joinable!(mod_ban_from_community -> community (community_id));
626 joinable!(mod_lock_post -> person (mod_person_id));
627 joinable!(mod_lock_post -> post (post_id));
628 joinable!(mod_remove_comment -> comment (comment_id));
629 joinable!(mod_remove_comment -> person (mod_person_id));
630 joinable!(mod_remove_community -> community (community_id));
631 joinable!(mod_remove_community -> person (mod_person_id));
632 joinable!(mod_remove_post -> person (mod_person_id));
633 joinable!(mod_remove_post -> post (post_id));
634 joinable!(mod_sticky_post -> person (mod_person_id));
635 joinable!(mod_sticky_post -> post (post_id));
636 joinable!(password_reset_request -> local_user (local_user_id));
637 joinable!(person_aggregates -> person (person_id));
638 joinable!(person_ban -> person (person_id));
639 joinable!(person_mention -> comment (comment_id));
640 joinable!(person_mention -> person (recipient_id));
641 joinable!(post -> community (community_id));
642 joinable!(post -> person (creator_id));
643 joinable!(post_aggregates -> post (post_id));
644 joinable!(post_like -> person (person_id));
645 joinable!(post_like -> post (post_id));
646 joinable!(post_read -> person (person_id));
647 joinable!(post_read -> post (post_id));
648 joinable!(post_report -> post (post_id));
649 joinable!(post_saved -> person (person_id));
650 joinable!(post_saved -> post (post_id));
651 joinable!(site -> person (creator_id));
652 joinable!(site_aggregates -> site (site_id));
653 joinable!(email_verification -> local_user (local_user_id));
654 joinable!(registration_application -> local_user (local_user_id));
655 joinable!(registration_application -> person (admin_id));
656
657 allow_tables_to_appear_in_same_query!(
658   activity,
659   comment,
660   comment_aggregates,
661   community_block,
662   comment_like,
663   comment_report,
664   comment_saved,
665   community,
666   community_aggregates,
667   community_follower,
668   community_moderator,
669   community_person_ban,
670   local_user,
671   mod_add,
672   mod_add_community,
673   mod_transfer_community,
674   mod_ban,
675   mod_ban_from_community,
676   mod_lock_post,
677   mod_remove_comment,
678   mod_remove_community,
679   mod_remove_post,
680   mod_sticky_post,
681   password_reset_request,
682   person,
683   person_aggregates,
684   person_ban,
685   person_block,
686   person_mention,
687   post,
688   post_aggregates,
689   post_like,
690   post_read,
691   post_report,
692   post_saved,
693   private_message,
694   site,
695   site_aggregates,
696   comment_alias_1,
697   person_alias_1,
698   person_alias_2,
699   email_verification,
700   registration_application
701 );