]> Untitled Git - lemmy.git/blob - crates/db_schema/src/schema.rs
Merge pull request #1328 from LemmyNet/move_views_to_diesel
[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     }
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         stickied -> Bool,
286         published -> 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     }
375 }
376
377 table! {
378     user_ (id) {
379         id -> Int4,
380         name -> Varchar,
381         preferred_username -> Nullable<Varchar>,
382         password_encrypted -> Text,
383         email -> Nullable<Text>,
384         avatar -> Nullable<Text>,
385         admin -> Bool,
386         banned -> Bool,
387         published -> Timestamp,
388         updated -> Nullable<Timestamp>,
389         show_nsfw -> Bool,
390         theme -> Varchar,
391         default_sort_type -> Int2,
392         default_listing_type -> Int2,
393         lang -> Varchar,
394         show_avatars -> Bool,
395         send_notifications_to_email -> Bool,
396         matrix_user_id -> Nullable<Text>,
397         actor_id -> Varchar,
398         bio -> Nullable<Text>,
399         local -> Bool,
400         private_key -> Nullable<Text>,
401         public_key -> Nullable<Text>,
402         last_refreshed_at -> Timestamp,
403         banner -> Nullable<Text>,
404         deleted -> Bool,
405     }
406 }
407
408 table! {
409     user_aggregates (id) {
410         id -> Int4,
411         user_id -> Int4,
412         post_count -> Int8,
413         post_score -> Int8,
414         comment_count -> Int8,
415         comment_score -> Int8,
416     }
417 }
418
419 table! {
420     user_ban (id) {
421         id -> Int4,
422         user_id -> Int4,
423         published -> Timestamp,
424     }
425 }
426
427 table! {
428     user_mention (id) {
429         id -> Int4,
430         recipient_id -> Int4,
431         comment_id -> Int4,
432         read -> Bool,
433         published -> Timestamp,
434     }
435 }
436
437 // These are necessary since diesel doesn't have self joins / aliases
438 table! {
439     comment_alias_1 (id) {
440         id -> Int4,
441         creator_id -> Int4,
442         post_id -> Int4,
443         parent_id -> Nullable<Int4>,
444         content -> Text,
445         removed -> Bool,
446         read -> Bool,
447         published -> Timestamp,
448         updated -> Nullable<Timestamp>,
449         deleted -> Bool,
450         ap_id -> Varchar,
451         local -> Bool,
452     }
453 }
454
455 table! {
456     user_alias_1 (id) {
457         id -> Int4,
458         name -> Varchar,
459         preferred_username -> Nullable<Varchar>,
460         password_encrypted -> Text,
461         email -> Nullable<Text>,
462         avatar -> Nullable<Text>,
463         admin -> Bool,
464         banned -> Bool,
465         published -> Timestamp,
466         updated -> Nullable<Timestamp>,
467         show_nsfw -> Bool,
468         theme -> Varchar,
469         default_sort_type -> Int2,
470         default_listing_type -> Int2,
471         lang -> Varchar,
472         show_avatars -> Bool,
473         send_notifications_to_email -> Bool,
474         matrix_user_id -> Nullable<Text>,
475         actor_id -> Varchar,
476         bio -> Nullable<Text>,
477         local -> Bool,
478         private_key -> Nullable<Text>,
479         public_key -> Nullable<Text>,
480         last_refreshed_at -> Timestamp,
481         banner -> Nullable<Text>,
482         deleted -> Bool,
483     }
484 }
485
486 table! {
487     user_alias_2 (id) {
488         id -> Int4,
489         name -> Varchar,
490         preferred_username -> Nullable<Varchar>,
491         password_encrypted -> Text,
492         email -> Nullable<Text>,
493         avatar -> Nullable<Text>,
494         admin -> Bool,
495         banned -> Bool,
496         published -> Timestamp,
497         updated -> Nullable<Timestamp>,
498         show_nsfw -> Bool,
499         theme -> Varchar,
500         default_sort_type -> Int2,
501         default_listing_type -> Int2,
502         lang -> Varchar,
503         show_avatars -> Bool,
504         send_notifications_to_email -> Bool,
505         matrix_user_id -> Nullable<Text>,
506         actor_id -> Varchar,
507         bio -> Nullable<Text>,
508         local -> Bool,
509         private_key -> Nullable<Text>,
510         public_key -> Nullable<Text>,
511         last_refreshed_at -> Timestamp,
512         banner -> Nullable<Text>,
513         deleted -> Bool,
514     }
515 }
516
517 joinable!(comment_alias_1 -> user_alias_1 (creator_id));
518 joinable!(comment -> comment_alias_1 (parent_id));
519 joinable!(user_mention -> user_alias_1 (recipient_id));
520 joinable!(post -> user_alias_1 (creator_id));
521 joinable!(comment -> user_alias_1 (creator_id));
522
523 joinable!(post_report -> user_alias_2 (resolver_id));
524 joinable!(comment_report -> user_alias_2 (resolver_id));
525
526 joinable!(comment -> post (post_id));
527 joinable!(comment -> user_ (creator_id));
528 joinable!(comment_aggregates -> comment (comment_id));
529 joinable!(comment_like -> comment (comment_id));
530 joinable!(comment_like -> post (post_id));
531 joinable!(comment_like -> user_ (user_id));
532 joinable!(comment_report -> comment (comment_id));
533 joinable!(comment_saved -> comment (comment_id));
534 joinable!(comment_saved -> user_ (user_id));
535 joinable!(community -> category (category_id));
536 joinable!(community -> user_ (creator_id));
537 joinable!(community_aggregates -> community (community_id));
538 joinable!(community_follower -> community (community_id));
539 joinable!(community_follower -> user_ (user_id));
540 joinable!(community_moderator -> community (community_id));
541 joinable!(community_moderator -> user_ (user_id));
542 joinable!(community_user_ban -> community (community_id));
543 joinable!(community_user_ban -> user_ (user_id));
544 joinable!(mod_add_community -> community (community_id));
545 joinable!(mod_ban_from_community -> community (community_id));
546 joinable!(mod_lock_post -> post (post_id));
547 joinable!(mod_lock_post -> user_ (mod_user_id));
548 joinable!(mod_remove_comment -> comment (comment_id));
549 joinable!(mod_remove_comment -> user_ (mod_user_id));
550 joinable!(mod_remove_community -> community (community_id));
551 joinable!(mod_remove_community -> user_ (mod_user_id));
552 joinable!(mod_remove_post -> post (post_id));
553 joinable!(mod_remove_post -> user_ (mod_user_id));
554 joinable!(mod_sticky_post -> post (post_id));
555 joinable!(mod_sticky_post -> user_ (mod_user_id));
556 joinable!(password_reset_request -> user_ (user_id));
557 joinable!(post -> community (community_id));
558 joinable!(post -> user_ (creator_id));
559 joinable!(post_aggregates -> post (post_id));
560 joinable!(post_like -> post (post_id));
561 joinable!(post_like -> user_ (user_id));
562 joinable!(post_read -> post (post_id));
563 joinable!(post_read -> user_ (user_id));
564 joinable!(post_report -> post (post_id));
565 joinable!(post_saved -> post (post_id));
566 joinable!(post_saved -> user_ (user_id));
567 joinable!(site -> user_ (creator_id));
568 joinable!(site_aggregates -> site (site_id));
569 joinable!(user_aggregates -> user_ (user_id));
570 joinable!(user_ban -> user_ (user_id));
571 joinable!(user_mention -> comment (comment_id));
572 joinable!(user_mention -> user_ (recipient_id));
573
574 allow_tables_to_appear_in_same_query!(
575   activity,
576   category,
577   comment,
578   comment_aggregates,
579   comment_like,
580   comment_report,
581   comment_saved,
582   community,
583   community_aggregates,
584   community_follower,
585   community_moderator,
586   community_user_ban,
587   mod_add,
588   mod_add_community,
589   mod_ban,
590   mod_ban_from_community,
591   mod_lock_post,
592   mod_remove_comment,
593   mod_remove_community,
594   mod_remove_post,
595   mod_sticky_post,
596   password_reset_request,
597   post,
598   post_aggregates,
599   post_like,
600   post_read,
601   post_report,
602   post_saved,
603   private_message,
604   site,
605   site_aggregates,
606   user_,
607   user_aggregates,
608   user_ban,
609   user_mention,
610   comment_alias_1,
611   user_alias_1,
612   user_alias_2,
613 );