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