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