]> Untitled Git - lemmy.git/blob - crates/db_schema/src/schema.rs
Store activitypub endpoints in database (#162)
[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 -> Timestamp,
295     }
296 }
297
298 table! {
299     post_like (id) {
300         id -> Int4,
301         post_id -> Int4,
302         user_id -> Int4,
303         score -> Int2,
304         published -> Timestamp,
305     }
306 }
307
308 table! {
309     post_read (id) {
310         id -> Int4,
311         post_id -> Int4,
312         user_id -> Int4,
313         published -> Timestamp,
314     }
315 }
316
317 table! {
318     post_report (id) {
319         id -> Int4,
320         creator_id -> Int4,
321         post_id -> Int4,
322         original_post_name -> Varchar,
323         original_post_url -> Nullable<Text>,
324         original_post_body -> Nullable<Text>,
325         reason -> Text,
326         resolved -> Bool,
327         resolver_id -> Nullable<Int4>,
328         published -> Timestamp,
329         updated -> Nullable<Timestamp>,
330     }
331 }
332
333 table! {
334     post_saved (id) {
335         id -> Int4,
336         post_id -> Int4,
337         user_id -> Int4,
338         published -> Timestamp,
339     }
340 }
341
342 table! {
343     private_message (id) {
344         id -> Int4,
345         creator_id -> Int4,
346         recipient_id -> Int4,
347         content -> Text,
348         deleted -> Bool,
349         read -> Bool,
350         published -> Timestamp,
351         updated -> Nullable<Timestamp>,
352         ap_id -> Varchar,
353         local -> Bool,
354     }
355 }
356
357 table! {
358     site (id) {
359         id -> Int4,
360         name -> Varchar,
361         description -> Nullable<Text>,
362         creator_id -> Int4,
363         published -> Timestamp,
364         updated -> Nullable<Timestamp>,
365         enable_downvotes -> Bool,
366         open_registration -> Bool,
367         enable_nsfw -> Bool,
368         icon -> Nullable<Text>,
369         banner -> Nullable<Text>,
370     }
371 }
372
373 table! {
374     site_aggregates (id) {
375         id -> Int4,
376         site_id -> Int4,
377         users -> Int8,
378         posts -> Int8,
379         comments -> Int8,
380         communities -> Int8,
381         users_active_day -> Int8,
382         users_active_week -> Int8,
383         users_active_month -> Int8,
384         users_active_half_year -> Int8,
385     }
386 }
387
388 table! {
389     user_ (id) {
390         id -> Int4,
391         name -> Varchar,
392         preferred_username -> Nullable<Varchar>,
393         password_encrypted -> Text,
394         email -> Nullable<Text>,
395         avatar -> Nullable<Text>,
396         admin -> Bool,
397         banned -> Bool,
398         published -> Timestamp,
399         updated -> Nullable<Timestamp>,
400         show_nsfw -> Bool,
401         theme -> Varchar,
402         default_sort_type -> Int2,
403         default_listing_type -> Int2,
404         lang -> Varchar,
405         show_avatars -> Bool,
406         send_notifications_to_email -> Bool,
407         matrix_user_id -> Nullable<Text>,
408         actor_id -> Varchar,
409         bio -> Nullable<Text>,
410         local -> Bool,
411         private_key -> Nullable<Text>,
412         public_key -> Nullable<Text>,
413         last_refreshed_at -> Timestamp,
414         banner -> Nullable<Text>,
415         deleted -> Bool,
416         inbox_url -> Text,
417         shared_inbox_url -> Nullable<Text>,
418     }
419 }
420
421 table! {
422     user_aggregates (id) {
423         id -> Int4,
424         user_id -> Int4,
425         post_count -> Int8,
426         post_score -> Int8,
427         comment_count -> Int8,
428         comment_score -> Int8,
429     }
430 }
431
432 table! {
433     user_ban (id) {
434         id -> Int4,
435         user_id -> Int4,
436         published -> Timestamp,
437     }
438 }
439
440 table! {
441     user_mention (id) {
442         id -> Int4,
443         recipient_id -> Int4,
444         comment_id -> Int4,
445         read -> Bool,
446         published -> Timestamp,
447     }
448 }
449
450 // These are necessary since diesel doesn't have self joins / aliases
451 table! {
452     comment_alias_1 (id) {
453         id -> Int4,
454         creator_id -> Int4,
455         post_id -> Int4,
456         parent_id -> Nullable<Int4>,
457         content -> Text,
458         removed -> Bool,
459         read -> Bool,
460         published -> Timestamp,
461         updated -> Nullable<Timestamp>,
462         deleted -> Bool,
463         ap_id -> Varchar,
464         local -> Bool,
465     }
466 }
467
468 table! {
469     user_alias_1 (id) {
470         id -> Int4,
471         name -> Varchar,
472         preferred_username -> Nullable<Varchar>,
473         password_encrypted -> Text,
474         email -> Nullable<Text>,
475         avatar -> Nullable<Text>,
476         admin -> Bool,
477         banned -> Bool,
478         published -> Timestamp,
479         updated -> Nullable<Timestamp>,
480         show_nsfw -> Bool,
481         theme -> Varchar,
482         default_sort_type -> Int2,
483         default_listing_type -> Int2,
484         lang -> Varchar,
485         show_avatars -> Bool,
486         send_notifications_to_email -> Bool,
487         matrix_user_id -> Nullable<Text>,
488         actor_id -> Varchar,
489         bio -> Nullable<Text>,
490         local -> Bool,
491         private_key -> Nullable<Text>,
492         public_key -> Nullable<Text>,
493         last_refreshed_at -> Timestamp,
494         banner -> Nullable<Text>,
495         deleted -> Bool,
496     }
497 }
498
499 table! {
500     user_alias_2 (id) {
501         id -> Int4,
502         name -> Varchar,
503         preferred_username -> Nullable<Varchar>,
504         password_encrypted -> Text,
505         email -> Nullable<Text>,
506         avatar -> Nullable<Text>,
507         admin -> Bool,
508         banned -> Bool,
509         published -> Timestamp,
510         updated -> Nullable<Timestamp>,
511         show_nsfw -> Bool,
512         theme -> Varchar,
513         default_sort_type -> Int2,
514         default_listing_type -> Int2,
515         lang -> Varchar,
516         show_avatars -> Bool,
517         send_notifications_to_email -> Bool,
518         matrix_user_id -> Nullable<Text>,
519         actor_id -> Varchar,
520         bio -> Nullable<Text>,
521         local -> Bool,
522         private_key -> Nullable<Text>,
523         public_key -> Nullable<Text>,
524         last_refreshed_at -> Timestamp,
525         banner -> Nullable<Text>,
526         deleted -> Bool,
527     }
528 }
529
530 joinable!(comment_alias_1 -> user_alias_1 (creator_id));
531 joinable!(comment -> comment_alias_1 (parent_id));
532 joinable!(user_mention -> user_alias_1 (recipient_id));
533 joinable!(post -> user_alias_1 (creator_id));
534 joinable!(comment -> user_alias_1 (creator_id));
535
536 joinable!(post_report -> user_alias_2 (resolver_id));
537 joinable!(comment_report -> user_alias_2 (resolver_id));
538
539 joinable!(comment -> post (post_id));
540 joinable!(comment -> user_ (creator_id));
541 joinable!(comment_aggregates -> comment (comment_id));
542 joinable!(comment_like -> comment (comment_id));
543 joinable!(comment_like -> post (post_id));
544 joinable!(comment_like -> user_ (user_id));
545 joinable!(comment_report -> comment (comment_id));
546 joinable!(comment_saved -> comment (comment_id));
547 joinable!(comment_saved -> user_ (user_id));
548 joinable!(community -> category (category_id));
549 joinable!(community -> user_ (creator_id));
550 joinable!(community_aggregates -> community (community_id));
551 joinable!(community_follower -> community (community_id));
552 joinable!(community_follower -> user_ (user_id));
553 joinable!(community_moderator -> community (community_id));
554 joinable!(community_moderator -> user_ (user_id));
555 joinable!(community_user_ban -> community (community_id));
556 joinable!(community_user_ban -> user_ (user_id));
557 joinable!(mod_add_community -> community (community_id));
558 joinable!(mod_ban_from_community -> community (community_id));
559 joinable!(mod_lock_post -> post (post_id));
560 joinable!(mod_lock_post -> user_ (mod_user_id));
561 joinable!(mod_remove_comment -> comment (comment_id));
562 joinable!(mod_remove_comment -> user_ (mod_user_id));
563 joinable!(mod_remove_community -> community (community_id));
564 joinable!(mod_remove_community -> user_ (mod_user_id));
565 joinable!(mod_remove_post -> post (post_id));
566 joinable!(mod_remove_post -> user_ (mod_user_id));
567 joinable!(mod_sticky_post -> post (post_id));
568 joinable!(mod_sticky_post -> user_ (mod_user_id));
569 joinable!(password_reset_request -> user_ (user_id));
570 joinable!(post -> community (community_id));
571 joinable!(post -> user_ (creator_id));
572 joinable!(post_aggregates -> post (post_id));
573 joinable!(post_like -> post (post_id));
574 joinable!(post_like -> user_ (user_id));
575 joinable!(post_read -> post (post_id));
576 joinable!(post_read -> user_ (user_id));
577 joinable!(post_report -> post (post_id));
578 joinable!(post_saved -> post (post_id));
579 joinable!(post_saved -> user_ (user_id));
580 joinable!(site -> user_ (creator_id));
581 joinable!(site_aggregates -> site (site_id));
582 joinable!(user_aggregates -> user_ (user_id));
583 joinable!(user_ban -> user_ (user_id));
584 joinable!(user_mention -> comment (comment_id));
585 joinable!(user_mention -> user_ (recipient_id));
586
587 allow_tables_to_appear_in_same_query!(
588   activity,
589   category,
590   comment,
591   comment_aggregates,
592   comment_like,
593   comment_report,
594   comment_saved,
595   community,
596   community_aggregates,
597   community_follower,
598   community_moderator,
599   community_user_ban,
600   mod_add,
601   mod_add_community,
602   mod_ban,
603   mod_ban_from_community,
604   mod_lock_post,
605   mod_remove_comment,
606   mod_remove_community,
607   mod_remove_post,
608   mod_sticky_post,
609   password_reset_request,
610   post,
611   post_aggregates,
612   post_like,
613   post_read,
614   post_report,
615   post_saved,
616   private_message,
617   site,
618   site_aggregates,
619   user_,
620   user_aggregates,
621   user_ban,
622   user_mention,
623   comment_alias_1,
624   user_alias_1,
625   user_alias_2,
626 );