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