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