]> Untitled Git - lemmy.git/blob - lemmy_db/src/schema.rs
b0c57f5e15e23bb919f526b0a8befbb79ba58eb5
[lemmy.git] / lemmy_db / 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 -> Nullable<Text>,
9         sensitive -> Nullable<Bool>,
10     }
11 }
12
13 table! {
14     category (id) {
15         id -> Int4,
16         name -> Varchar,
17     }
18 }
19
20 table! {
21     comment (id) {
22         id -> Int4,
23         creator_id -> Int4,
24         post_id -> Int4,
25         parent_id -> Nullable<Int4>,
26         content -> Text,
27         removed -> Bool,
28         read -> Bool,
29         published -> Timestamp,
30         updated -> Nullable<Timestamp>,
31         deleted -> Bool,
32         ap_id -> Varchar,
33         local -> Bool,
34     }
35 }
36
37 table! {
38     comment_aggregates_fast (id) {
39         id -> Int4,
40         creator_id -> Nullable<Int4>,
41         post_id -> Nullable<Int4>,
42         parent_id -> Nullable<Int4>,
43         content -> Nullable<Text>,
44         removed -> Nullable<Bool>,
45         read -> Nullable<Bool>,
46         published -> Nullable<Timestamp>,
47         updated -> Nullable<Timestamp>,
48         deleted -> Nullable<Bool>,
49         ap_id -> Nullable<Varchar>,
50         local -> Nullable<Bool>,
51         post_name -> Nullable<Varchar>,
52         community_id -> Nullable<Int4>,
53         community_actor_id -> Nullable<Varchar>,
54         community_local -> Nullable<Bool>,
55         community_name -> Nullable<Varchar>,
56         community_icon -> Nullable<Text>,
57         banned -> Nullable<Bool>,
58         banned_from_community -> Nullable<Bool>,
59         creator_actor_id -> Nullable<Varchar>,
60         creator_local -> Nullable<Bool>,
61         creator_name -> Nullable<Varchar>,
62         creator_preferred_username -> Nullable<Varchar>,
63         creator_published -> Nullable<Timestamp>,
64         creator_avatar -> Nullable<Text>,
65         score -> Nullable<Int8>,
66         upvotes -> Nullable<Int8>,
67         downvotes -> Nullable<Int8>,
68         hot_rank -> Nullable<Int4>,
69         hot_rank_active -> Nullable<Int4>,
70     }
71 }
72
73 table! {
74     comment_like (id) {
75         id -> Int4,
76         user_id -> Int4,
77         comment_id -> Int4,
78         post_id -> Int4,
79         score -> Int2,
80         published -> Timestamp,
81     }
82 }
83
84 table! {
85     comment_report (id) {
86         id -> Int4,
87         creator_id -> Int4,
88         comment_id -> Int4,
89         original_comment_text -> Text,
90         reason -> Text,
91         resolved -> Bool,
92         resolver_id -> Nullable<Int4>,
93         published -> Timestamp,
94         updated -> Nullable<Timestamp>,
95     }
96 }
97
98 table! {
99     comment_saved (id) {
100         id -> Int4,
101         comment_id -> Int4,
102         user_id -> Int4,
103         published -> Timestamp,
104     }
105 }
106
107 table! {
108     community (id) {
109         id -> Int4,
110         name -> Varchar,
111         title -> Varchar,
112         description -> Nullable<Text>,
113         category_id -> Int4,
114         creator_id -> Int4,
115         removed -> Bool,
116         published -> Timestamp,
117         updated -> Nullable<Timestamp>,
118         deleted -> Bool,
119         nsfw -> Bool,
120         actor_id -> Varchar,
121         local -> Bool,
122         private_key -> Nullable<Text>,
123         public_key -> Nullable<Text>,
124         last_refreshed_at -> Timestamp,
125         icon -> Nullable<Text>,
126         banner -> Nullable<Text>,
127     }
128 }
129
130 table! {
131     community_aggregates (id) {
132         id -> Int4,
133         community_id -> Int4,
134         subscribers -> Int8,
135         posts -> Int8,
136         comments -> Int8,
137     }
138 }
139
140 table! {
141     community_aggregates_fast (id) {
142         id -> Int4,
143         name -> Nullable<Varchar>,
144         title -> Nullable<Varchar>,
145         icon -> Nullable<Text>,
146         banner -> Nullable<Text>,
147         description -> Nullable<Text>,
148         category_id -> Nullable<Int4>,
149         creator_id -> Nullable<Int4>,
150         removed -> Nullable<Bool>,
151         published -> Nullable<Timestamp>,
152         updated -> Nullable<Timestamp>,
153         deleted -> Nullable<Bool>,
154         nsfw -> Nullable<Bool>,
155         actor_id -> Nullable<Varchar>,
156         local -> Nullable<Bool>,
157         last_refreshed_at -> Nullable<Timestamp>,
158         creator_actor_id -> Nullable<Varchar>,
159         creator_local -> Nullable<Bool>,
160         creator_name -> Nullable<Varchar>,
161         creator_preferred_username -> Nullable<Varchar>,
162         creator_avatar -> Nullable<Text>,
163         category_name -> Nullable<Varchar>,
164         number_of_subscribers -> Nullable<Int8>,
165         number_of_posts -> Nullable<Int8>,
166         number_of_comments -> Nullable<Int8>,
167         hot_rank -> Nullable<Int4>,
168     }
169 }
170
171 table! {
172     community_follower (id) {
173         id -> Int4,
174         community_id -> Int4,
175         user_id -> Int4,
176         published -> Timestamp,
177         pending -> Nullable<Bool>,
178     }
179 }
180
181 table! {
182     community_moderator (id) {
183         id -> Int4,
184         community_id -> Int4,
185         user_id -> Int4,
186         published -> Timestamp,
187     }
188 }
189
190 table! {
191     community_user_ban (id) {
192         id -> Int4,
193         community_id -> Int4,
194         user_id -> Int4,
195         published -> Timestamp,
196     }
197 }
198
199 table! {
200     mod_add (id) {
201         id -> Int4,
202         mod_user_id -> Int4,
203         other_user_id -> Int4,
204         removed -> Nullable<Bool>,
205         when_ -> Timestamp,
206     }
207 }
208
209 table! {
210     mod_add_community (id) {
211         id -> Int4,
212         mod_user_id -> Int4,
213         other_user_id -> Int4,
214         community_id -> Int4,
215         removed -> Nullable<Bool>,
216         when_ -> Timestamp,
217     }
218 }
219
220 table! {
221     mod_ban (id) {
222         id -> Int4,
223         mod_user_id -> Int4,
224         other_user_id -> Int4,
225         reason -> Nullable<Text>,
226         banned -> Nullable<Bool>,
227         expires -> Nullable<Timestamp>,
228         when_ -> Timestamp,
229     }
230 }
231
232 table! {
233     mod_ban_from_community (id) {
234         id -> Int4,
235         mod_user_id -> Int4,
236         other_user_id -> Int4,
237         community_id -> Int4,
238         reason -> Nullable<Text>,
239         banned -> Nullable<Bool>,
240         expires -> Nullable<Timestamp>,
241         when_ -> Timestamp,
242     }
243 }
244
245 table! {
246     mod_lock_post (id) {
247         id -> Int4,
248         mod_user_id -> Int4,
249         post_id -> Int4,
250         locked -> Nullable<Bool>,
251         when_ -> Timestamp,
252     }
253 }
254
255 table! {
256     mod_remove_comment (id) {
257         id -> Int4,
258         mod_user_id -> Int4,
259         comment_id -> Int4,
260         reason -> Nullable<Text>,
261         removed -> Nullable<Bool>,
262         when_ -> Timestamp,
263     }
264 }
265
266 table! {
267     mod_remove_community (id) {
268         id -> Int4,
269         mod_user_id -> Int4,
270         community_id -> Int4,
271         reason -> Nullable<Text>,
272         removed -> Nullable<Bool>,
273         expires -> Nullable<Timestamp>,
274         when_ -> Timestamp,
275     }
276 }
277
278 table! {
279     mod_remove_post (id) {
280         id -> Int4,
281         mod_user_id -> Int4,
282         post_id -> Int4,
283         reason -> Nullable<Text>,
284         removed -> Nullable<Bool>,
285         when_ -> Timestamp,
286     }
287 }
288
289 table! {
290     mod_sticky_post (id) {
291         id -> Int4,
292         mod_user_id -> Int4,
293         post_id -> Int4,
294         stickied -> Nullable<Bool>,
295         when_ -> Timestamp,
296     }
297 }
298
299 table! {
300     password_reset_request (id) {
301         id -> Int4,
302         user_id -> Int4,
303         token_encrypted -> Text,
304         published -> Timestamp,
305     }
306 }
307
308 table! {
309     post (id) {
310         id -> Int4,
311         name -> Varchar,
312         url -> Nullable<Text>,
313         body -> Nullable<Text>,
314         creator_id -> Int4,
315         community_id -> Int4,
316         removed -> Bool,
317         locked -> Bool,
318         published -> Timestamp,
319         updated -> Nullable<Timestamp>,
320         deleted -> Bool,
321         nsfw -> Bool,
322         stickied -> Bool,
323         embed_title -> Nullable<Text>,
324         embed_description -> Nullable<Text>,
325         embed_html -> Nullable<Text>,
326         thumbnail_url -> Nullable<Text>,
327         ap_id -> Varchar,
328         local -> Bool,
329     }
330 }
331
332 table! {
333     post_aggregates (id) {
334         id -> Int4,
335         post_id -> Int4,
336         comments -> Int8,
337         score -> Int8,
338         upvotes -> Int8,
339         downvotes -> Int8,
340         newest_comment_time -> Timestamp,
341     }
342 }
343
344 table! {
345     post_aggregates_fast (id) {
346         id -> Int4,
347         name -> Nullable<Varchar>,
348         url -> Nullable<Text>,
349         body -> Nullable<Text>,
350         creator_id -> Nullable<Int4>,
351         community_id -> Nullable<Int4>,
352         removed -> Nullable<Bool>,
353         locked -> Nullable<Bool>,
354         published -> Nullable<Timestamp>,
355         updated -> Nullable<Timestamp>,
356         deleted -> Nullable<Bool>,
357         nsfw -> Nullable<Bool>,
358         stickied -> Nullable<Bool>,
359         embed_title -> Nullable<Text>,
360         embed_description -> Nullable<Text>,
361         embed_html -> Nullable<Text>,
362         thumbnail_url -> Nullable<Text>,
363         ap_id -> Nullable<Varchar>,
364         local -> Nullable<Bool>,
365         creator_actor_id -> Nullable<Varchar>,
366         creator_local -> Nullable<Bool>,
367         creator_name -> Nullable<Varchar>,
368         creator_preferred_username -> Nullable<Varchar>,
369         creator_published -> Nullable<Timestamp>,
370         creator_avatar -> Nullable<Text>,
371         banned -> Nullable<Bool>,
372         banned_from_community -> Nullable<Bool>,
373         community_actor_id -> Nullable<Varchar>,
374         community_local -> Nullable<Bool>,
375         community_name -> Nullable<Varchar>,
376         community_icon -> Nullable<Text>,
377         community_removed -> Nullable<Bool>,
378         community_deleted -> Nullable<Bool>,
379         community_nsfw -> Nullable<Bool>,
380         number_of_comments -> Nullable<Int8>,
381         score -> Nullable<Int8>,
382         upvotes -> Nullable<Int8>,
383         downvotes -> Nullable<Int8>,
384         hot_rank -> Nullable<Int4>,
385         hot_rank_active -> Nullable<Int4>,
386         newest_activity_time -> Nullable<Timestamp>,
387     }
388 }
389
390 table! {
391     post_like (id) {
392         id -> Int4,
393         post_id -> Int4,
394         user_id -> Int4,
395         score -> Int2,
396         published -> Timestamp,
397     }
398 }
399
400 table! {
401     post_read (id) {
402         id -> Int4,
403         post_id -> Int4,
404         user_id -> Int4,
405         published -> Timestamp,
406     }
407 }
408
409 table! {
410     post_report (id) {
411         id -> Int4,
412         creator_id -> Int4,
413         post_id -> Int4,
414         original_post_name -> Varchar,
415         original_post_url -> Nullable<Text>,
416         original_post_body -> Nullable<Text>,
417         reason -> Text,
418         resolved -> Bool,
419         resolver_id -> Nullable<Int4>,
420         published -> Timestamp,
421         updated -> Nullable<Timestamp>,
422     }
423 }
424
425 table! {
426     post_saved (id) {
427         id -> Int4,
428         post_id -> Int4,
429         user_id -> Int4,
430         published -> Timestamp,
431     }
432 }
433
434 table! {
435     private_message (id) {
436         id -> Int4,
437         creator_id -> Int4,
438         recipient_id -> Int4,
439         content -> Text,
440         deleted -> Bool,
441         read -> Bool,
442         published -> Timestamp,
443         updated -> Nullable<Timestamp>,
444         ap_id -> Varchar,
445         local -> Bool,
446     }
447 }
448
449 table! {
450     site (id) {
451         id -> Int4,
452         name -> Varchar,
453         description -> Nullable<Text>,
454         creator_id -> Int4,
455         published -> Timestamp,
456         updated -> Nullable<Timestamp>,
457         enable_downvotes -> Bool,
458         open_registration -> Bool,
459         enable_nsfw -> Bool,
460         icon -> Nullable<Text>,
461         banner -> Nullable<Text>,
462     }
463 }
464
465 table! {
466     site_aggregates (id) {
467         id -> Int4,
468         users -> Int8,
469         posts -> Int8,
470         comments -> Int8,
471         communities -> Int8,
472     }
473 }
474
475 table! {
476     user_ (id) {
477         id -> Int4,
478         name -> Varchar,
479         preferred_username -> Nullable<Varchar>,
480         password_encrypted -> Text,
481         email -> Nullable<Text>,
482         avatar -> Nullable<Text>,
483         admin -> Bool,
484         banned -> Bool,
485         published -> Timestamp,
486         updated -> Nullable<Timestamp>,
487         show_nsfw -> Bool,
488         theme -> Varchar,
489         default_sort_type -> Int2,
490         default_listing_type -> Int2,
491         lang -> Varchar,
492         show_avatars -> Bool,
493         send_notifications_to_email -> Bool,
494         matrix_user_id -> Nullable<Text>,
495         actor_id -> Varchar,
496         bio -> Nullable<Text>,
497         local -> Bool,
498         private_key -> Nullable<Text>,
499         public_key -> Nullable<Text>,
500         last_refreshed_at -> Timestamp,
501         banner -> Nullable<Text>,
502         deleted -> Bool,
503     }
504 }
505
506 table! {
507     user_aggregates (id) {
508         id -> Int4,
509         user_id -> Int4,
510         post_count -> Int8,
511         post_score -> Int8,
512         comment_count -> Int8,
513         comment_score -> Int8,
514     }
515 }
516
517 table! {
518     user_ban (id) {
519         id -> Int4,
520         user_id -> Int4,
521         published -> Timestamp,
522     }
523 }
524
525 table! {
526     user_fast (id) {
527         id -> Int4,
528         actor_id -> Nullable<Varchar>,
529         name -> Nullable<Varchar>,
530         preferred_username -> Nullable<Varchar>,
531         avatar -> Nullable<Text>,
532         banner -> Nullable<Text>,
533         email -> Nullable<Text>,
534         matrix_user_id -> Nullable<Text>,
535         bio -> Nullable<Text>,
536         local -> Nullable<Bool>,
537         admin -> Nullable<Bool>,
538         banned -> Nullable<Bool>,
539         show_avatars -> Nullable<Bool>,
540         send_notifications_to_email -> Nullable<Bool>,
541         published -> Nullable<Timestamp>,
542         number_of_posts -> Nullable<Int8>,
543         post_score -> Nullable<Int8>,
544         number_of_comments -> Nullable<Int8>,
545         comment_score -> Nullable<Int8>,
546     }
547 }
548
549 table! {
550     user_mention (id) {
551         id -> Int4,
552         recipient_id -> Int4,
553         comment_id -> Int4,
554         read -> Bool,
555         published -> Timestamp,
556     }
557 }
558
559 joinable!(comment -> post (post_id));
560 joinable!(comment -> user_ (creator_id));
561 joinable!(comment_like -> comment (comment_id));
562 joinable!(comment_like -> post (post_id));
563 joinable!(comment_like -> user_ (user_id));
564 joinable!(comment_report -> comment (comment_id));
565 joinable!(comment_saved -> comment (comment_id));
566 joinable!(comment_saved -> user_ (user_id));
567 joinable!(community -> category (category_id));
568 joinable!(community -> user_ (creator_id));
569 joinable!(community_aggregates -> community (community_id));
570 joinable!(community_follower -> community (community_id));
571 joinable!(community_follower -> user_ (user_id));
572 joinable!(community_moderator -> community (community_id));
573 joinable!(community_moderator -> user_ (user_id));
574 joinable!(community_user_ban -> community (community_id));
575 joinable!(community_user_ban -> user_ (user_id));
576 joinable!(mod_add_community -> community (community_id));
577 joinable!(mod_ban_from_community -> community (community_id));
578 joinable!(mod_lock_post -> post (post_id));
579 joinable!(mod_lock_post -> user_ (mod_user_id));
580 joinable!(mod_remove_comment -> comment (comment_id));
581 joinable!(mod_remove_comment -> user_ (mod_user_id));
582 joinable!(mod_remove_community -> community (community_id));
583 joinable!(mod_remove_community -> user_ (mod_user_id));
584 joinable!(mod_remove_post -> post (post_id));
585 joinable!(mod_remove_post -> user_ (mod_user_id));
586 joinable!(mod_sticky_post -> post (post_id));
587 joinable!(mod_sticky_post -> user_ (mod_user_id));
588 joinable!(password_reset_request -> user_ (user_id));
589 joinable!(post -> community (community_id));
590 joinable!(post -> user_ (creator_id));
591 joinable!(post_aggregates -> post (post_id));
592 joinable!(post_like -> post (post_id));
593 joinable!(post_like -> user_ (user_id));
594 joinable!(post_read -> post (post_id));
595 joinable!(post_read -> user_ (user_id));
596 joinable!(post_report -> post (post_id));
597 joinable!(post_saved -> post (post_id));
598 joinable!(post_saved -> user_ (user_id));
599 joinable!(site -> user_ (creator_id));
600 joinable!(user_aggregates -> user_ (user_id));
601 joinable!(user_ban -> user_ (user_id));
602 joinable!(user_mention -> comment (comment_id));
603 joinable!(user_mention -> user_ (recipient_id));
604
605 allow_tables_to_appear_in_same_query!(
606   activity,
607   category,
608   comment,
609   comment_aggregates_fast,
610   comment_like,
611   comment_report,
612   comment_saved,
613   community,
614   community_aggregates,
615   community_aggregates_fast,
616   community_follower,
617   community_moderator,
618   community_user_ban,
619   mod_add,
620   mod_add_community,
621   mod_ban,
622   mod_ban_from_community,
623   mod_lock_post,
624   mod_remove_comment,
625   mod_remove_community,
626   mod_remove_post,
627   mod_sticky_post,
628   password_reset_request,
629   post,
630   post_aggregates,
631   post_aggregates_fast,
632   post_like,
633   post_read,
634   post_report,
635   post_saved,
636   private_message,
637   site,
638   site_aggregates,
639   user_,
640   user_aggregates,
641   user_ban,
642   user_fast,
643   user_mention,
644 );