]> Untitled Git - lemmy.git/blob - lemmy_db/src/schema.rs
e6dd6d4bd2f6b4c8dd452e51bff7c7549915573d
[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_fast (id) {
334         id -> Int4,
335         name -> Nullable<Varchar>,
336         url -> Nullable<Text>,
337         body -> Nullable<Text>,
338         creator_id -> Nullable<Int4>,
339         community_id -> Nullable<Int4>,
340         removed -> Nullable<Bool>,
341         locked -> Nullable<Bool>,
342         published -> Nullable<Timestamp>,
343         updated -> Nullable<Timestamp>,
344         deleted -> Nullable<Bool>,
345         nsfw -> Nullable<Bool>,
346         stickied -> Nullable<Bool>,
347         embed_title -> Nullable<Text>,
348         embed_description -> Nullable<Text>,
349         embed_html -> Nullable<Text>,
350         thumbnail_url -> Nullable<Text>,
351         ap_id -> Nullable<Varchar>,
352         local -> Nullable<Bool>,
353         creator_actor_id -> Nullable<Varchar>,
354         creator_local -> Nullable<Bool>,
355         creator_name -> Nullable<Varchar>,
356         creator_preferred_username -> Nullable<Varchar>,
357         creator_published -> Nullable<Timestamp>,
358         creator_avatar -> Nullable<Text>,
359         banned -> Nullable<Bool>,
360         banned_from_community -> Nullable<Bool>,
361         community_actor_id -> Nullable<Varchar>,
362         community_local -> Nullable<Bool>,
363         community_name -> Nullable<Varchar>,
364         community_icon -> Nullable<Text>,
365         community_removed -> Nullable<Bool>,
366         community_deleted -> Nullable<Bool>,
367         community_nsfw -> Nullable<Bool>,
368         number_of_comments -> Nullable<Int8>,
369         score -> Nullable<Int8>,
370         upvotes -> Nullable<Int8>,
371         downvotes -> Nullable<Int8>,
372         hot_rank -> Nullable<Int4>,
373         hot_rank_active -> Nullable<Int4>,
374         newest_activity_time -> Nullable<Timestamp>,
375     }
376 }
377
378 table! {
379     post_like (id) {
380         id -> Int4,
381         post_id -> Int4,
382         user_id -> Int4,
383         score -> Int2,
384         published -> Timestamp,
385     }
386 }
387
388 table! {
389     post_read (id) {
390         id -> Int4,
391         post_id -> Int4,
392         user_id -> Int4,
393         published -> Timestamp,
394     }
395 }
396
397 table! {
398     post_report (id) {
399         id -> Int4,
400         creator_id -> Int4,
401         post_id -> Int4,
402         original_post_name -> Varchar,
403         original_post_url -> Nullable<Text>,
404         original_post_body -> Nullable<Text>,
405         reason -> Text,
406         resolved -> Bool,
407         resolver_id -> Nullable<Int4>,
408         published -> Timestamp,
409         updated -> Nullable<Timestamp>,
410     }
411 }
412
413 table! {
414     post_saved (id) {
415         id -> Int4,
416         post_id -> Int4,
417         user_id -> Int4,
418         published -> Timestamp,
419     }
420 }
421
422 table! {
423     private_message (id) {
424         id -> Int4,
425         creator_id -> Int4,
426         recipient_id -> Int4,
427         content -> Text,
428         deleted -> Bool,
429         read -> Bool,
430         published -> Timestamp,
431         updated -> Nullable<Timestamp>,
432         ap_id -> Varchar,
433         local -> Bool,
434     }
435 }
436
437 table! {
438     site (id) {
439         id -> Int4,
440         name -> Varchar,
441         description -> Nullable<Text>,
442         creator_id -> Int4,
443         published -> Timestamp,
444         updated -> Nullable<Timestamp>,
445         enable_downvotes -> Bool,
446         open_registration -> Bool,
447         enable_nsfw -> Bool,
448         icon -> Nullable<Text>,
449         banner -> Nullable<Text>,
450     }
451 }
452
453 table! {
454     site_aggregates (id) {
455         id -> Int4,
456         users -> Int8,
457         posts -> Int8,
458         comments -> Int8,
459         communities -> Int8,
460     }
461 }
462
463 table! {
464     user_ (id) {
465         id -> Int4,
466         name -> Varchar,
467         preferred_username -> Nullable<Varchar>,
468         password_encrypted -> Text,
469         email -> Nullable<Text>,
470         avatar -> Nullable<Text>,
471         admin -> Bool,
472         banned -> Bool,
473         published -> Timestamp,
474         updated -> Nullable<Timestamp>,
475         show_nsfw -> Bool,
476         theme -> Varchar,
477         default_sort_type -> Int2,
478         default_listing_type -> Int2,
479         lang -> Varchar,
480         show_avatars -> Bool,
481         send_notifications_to_email -> Bool,
482         matrix_user_id -> Nullable<Text>,
483         actor_id -> Varchar,
484         bio -> Nullable<Text>,
485         local -> Bool,
486         private_key -> Nullable<Text>,
487         public_key -> Nullable<Text>,
488         last_refreshed_at -> Timestamp,
489         banner -> Nullable<Text>,
490         deleted -> Bool,
491     }
492 }
493
494 table! {
495     user_aggregates (id) {
496         id -> Int4,
497         user_id -> Int4,
498         post_count -> Int8,
499         post_score -> Int8,
500         comment_count -> Int8,
501         comment_score -> Int8,
502     }
503 }
504
505 table! {
506     user_ban (id) {
507         id -> Int4,
508         user_id -> Int4,
509         published -> Timestamp,
510     }
511 }
512
513 table! {
514     user_fast (id) {
515         id -> Int4,
516         actor_id -> Nullable<Varchar>,
517         name -> Nullable<Varchar>,
518         preferred_username -> Nullable<Varchar>,
519         avatar -> Nullable<Text>,
520         banner -> Nullable<Text>,
521         email -> Nullable<Text>,
522         matrix_user_id -> Nullable<Text>,
523         bio -> Nullable<Text>,
524         local -> Nullable<Bool>,
525         admin -> Nullable<Bool>,
526         banned -> Nullable<Bool>,
527         show_avatars -> Nullable<Bool>,
528         send_notifications_to_email -> Nullable<Bool>,
529         published -> Nullable<Timestamp>,
530         number_of_posts -> Nullable<Int8>,
531         post_score -> Nullable<Int8>,
532         number_of_comments -> Nullable<Int8>,
533         comment_score -> Nullable<Int8>,
534     }
535 }
536
537 table! {
538     user_mention (id) {
539         id -> Int4,
540         recipient_id -> Int4,
541         comment_id -> Int4,
542         read -> Bool,
543         published -> Timestamp,
544     }
545 }
546
547 joinable!(comment -> post (post_id));
548 joinable!(comment -> user_ (creator_id));
549 joinable!(comment_like -> comment (comment_id));
550 joinable!(comment_like -> post (post_id));
551 joinable!(comment_like -> user_ (user_id));
552 joinable!(comment_report -> comment (comment_id));
553 joinable!(comment_saved -> comment (comment_id));
554 joinable!(comment_saved -> user_ (user_id));
555 joinable!(community -> category (category_id));
556 joinable!(community -> user_ (creator_id));
557 joinable!(community_aggregates -> community (community_id));
558 joinable!(community_follower -> community (community_id));
559 joinable!(community_follower -> user_ (user_id));
560 joinable!(community_moderator -> community (community_id));
561 joinable!(community_moderator -> user_ (user_id));
562 joinable!(community_user_ban -> community (community_id));
563 joinable!(community_user_ban -> user_ (user_id));
564 joinable!(mod_add_community -> community (community_id));
565 joinable!(mod_ban_from_community -> community (community_id));
566 joinable!(mod_lock_post -> post (post_id));
567 joinable!(mod_lock_post -> user_ (mod_user_id));
568 joinable!(mod_remove_comment -> comment (comment_id));
569 joinable!(mod_remove_comment -> user_ (mod_user_id));
570 joinable!(mod_remove_community -> community (community_id));
571 joinable!(mod_remove_community -> user_ (mod_user_id));
572 joinable!(mod_remove_post -> post (post_id));
573 joinable!(mod_remove_post -> user_ (mod_user_id));
574 joinable!(mod_sticky_post -> post (post_id));
575 joinable!(mod_sticky_post -> user_ (mod_user_id));
576 joinable!(password_reset_request -> user_ (user_id));
577 joinable!(post -> community (community_id));
578 joinable!(post -> user_ (creator_id));
579 joinable!(post_like -> post (post_id));
580 joinable!(post_like -> user_ (user_id));
581 joinable!(post_read -> post (post_id));
582 joinable!(post_read -> user_ (user_id));
583 joinable!(post_report -> post (post_id));
584 joinable!(post_saved -> post (post_id));
585 joinable!(post_saved -> user_ (user_id));
586 joinable!(site -> user_ (creator_id));
587 joinable!(user_aggregates -> user_ (user_id));
588 joinable!(user_ban -> user_ (user_id));
589 joinable!(user_mention -> comment (comment_id));
590 joinable!(user_mention -> user_ (recipient_id));
591
592 allow_tables_to_appear_in_same_query!(
593   activity,
594   category,
595   comment,
596   comment_aggregates_fast,
597   comment_like,
598   comment_report,
599   comment_saved,
600   community,
601   community_aggregates,
602   community_aggregates_fast,
603   community_follower,
604   community_moderator,
605   community_user_ban,
606   mod_add,
607   mod_add_community,
608   mod_ban,
609   mod_ban_from_community,
610   mod_lock_post,
611   mod_remove_comment,
612   mod_remove_community,
613   mod_remove_post,
614   mod_sticky_post,
615   password_reset_request,
616   post,
617   post_aggregates_fast,
618   post_like,
619   post_read,
620   post_report,
621   post_saved,
622   private_message,
623   site,
624   site_aggregates,
625   user_,
626   user_aggregates,
627   user_ban,
628   user_fast,
629   user_mention,
630 );