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