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