]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/site.rs
Merge branch 'main' into feature/mark_post_as_read
[lemmy.git] / crates / db_schema / src / source / site.rs
1 use crate::{schema::site, DbUrl, PersonId};
2 use serde::Serialize;
3
4 #[derive(Queryable, Identifiable, PartialEq, Debug, Clone, Serialize)]
5 #[table_name = "site"]
6 pub struct Site {
7   pub id: i32,
8   pub name: String,
9   pub sidebar: Option<String>,
10   pub creator_id: PersonId,
11   pub published: chrono::NaiveDateTime,
12   pub updated: Option<chrono::NaiveDateTime>,
13   pub enable_downvotes: bool,
14   pub open_registration: bool,
15   pub enable_nsfw: bool,
16   pub icon: Option<DbUrl>,
17   pub banner: Option<DbUrl>,
18   pub description: Option<String>,
19   pub community_creation_admin_only: bool,
20 }
21
22 #[derive(Insertable, AsChangeset)]
23 #[table_name = "site"]
24 pub struct SiteForm {
25   pub name: String,
26   pub creator_id: PersonId,
27   pub sidebar: Option<Option<String>>,
28   pub updated: Option<chrono::NaiveDateTime>,
29   pub enable_downvotes: Option<bool>,
30   pub open_registration: Option<bool>,
31   pub enable_nsfw: Option<bool>,
32   // when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
33   pub icon: Option<Option<DbUrl>>,
34   pub banner: Option<Option<DbUrl>>,
35   pub description: Option<Option<String>>,
36   pub community_creation_admin_only: Option<bool>,
37 }