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