Skip to content

Commit

Permalink
Add serialization for datetime fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Oct 8, 2024
1 parent dee32c6 commit 10ccba0
Show file tree
Hide file tree
Showing 24 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions deepwell/src/models/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Model {
#[sea_orm(primary_key)]
pub alias_id: i64,
pub alias_type: AliasType,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
pub created_by: i64,
pub target_id: i64,
Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/blob_pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub external_id: String,
pub created_by: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339")]
pub expires_at: TimeDateTimeWithTimeZone,
pub expected_length: i64,
#[sea_orm(column_type = "Text")]
Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub file_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
pub from_wikidot: bool,
#[sea_orm(column_type = "Text")]
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/models/file_revision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Model {
#[sea_orm(primary_key)]
pub revision_id: i64,
pub revision_type: FileRevisionType,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
pub revision_number: i32,
pub file_id: i64,
Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub filter_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
pub site_id: Option<i64>,
pub affects_user: bool,
Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/message_draft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub external_id: String,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
pub user_id: i64,
pub recipients: Json,
Expand All @@ -18,6 +20,7 @@ pub struct Model {
pub wikitext_hash: Vec<u8>,
#[sea_orm(column_type = "VarBinary(StringLen::None)")]
pub compiled_hash: Vec<u8>,
#[serde(with = "time::serde::rfc3339")]
pub compiled_at: TimeDateTimeWithTimeZone,
#[sea_orm(column_type = "Text")]
pub compiled_generator: String,
Expand Down
4 changes: 4 additions & 0 deletions deepwell/src/models/message_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub external_id: String,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339")]
pub drafted_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub retracted_at: Option<TimeDateTimeWithTimeZone>,
pub sender_id: i64,
#[sea_orm(column_type = "Text")]
Expand All @@ -18,6 +21,7 @@ pub struct Model {
pub wikitext_hash: Vec<u8>,
#[sea_orm(column_type = "VarBinary(StringLen::None)")]
pub compiled_hash: Vec<u8>,
#[serde(with = "time::serde::rfc3339")]
pub compiled_at: TimeDateTimeWithTimeZone,
#[sea_orm(column_type = "Text")]
pub compiled_generator: String,
Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/message_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ pub struct Model {
pub message_id: i64,
#[sea_orm(primary_key, auto_increment = false)]
pub reported_to_site_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[sea_orm(column_type = "Text")]
pub reason: String,
Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub page_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
pub from_wikidot: bool,
pub site_id: i64,
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/models/page_attribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Model {
pub attribution_type: String,
#[sea_orm(primary_key, auto_increment = false)]
pub attribution_date: TimeDate,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
}

Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/page_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub category_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
pub site_id: i64,
#[sea_orm(column_type = "Text")]
Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/page_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ pub struct Model {
pub to_page_id: i64,
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub connection_type: String,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
pub count: i32,
}
Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/page_connection_missing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ pub struct Model {
pub to_page_slug: String,
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub connection_type: String,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
pub count: i32,
}
Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/page_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ pub struct Model {
pub page_id: i64,
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub url: String,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
pub count: i32,
}
Expand Down
4 changes: 4 additions & 0 deletions deepwell/src/models/page_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub page_lock_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub expires_at: Option<TimeDateTimeWithTimeZone>,
pub from_wikidot: bool,
#[sea_orm(column_type = "Text")]
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/models/page_parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Model {
pub parent_page_id: i64,
#[sea_orm(primary_key, auto_increment = false)]
pub child_page_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
}

Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/page_revision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ pub struct Model {
#[sea_orm(primary_key)]
pub revision_id: i64,
pub revision_type: PageRevisionType,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
pub revision_number: i32,
pub page_id: i64,
Expand All @@ -22,6 +24,7 @@ pub struct Model {
pub wikitext_hash: Vec<u8>,
#[sea_orm(column_type = "VarBinary(StringLen::None)")]
pub compiled_hash: Vec<u8>,
#[serde(with = "time::serde::rfc3339")]
pub compiled_at: TimeDateTimeWithTimeZone,
#[sea_orm(column_type = "Text")]
pub compiled_generator: String,
Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/page_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub page_vote_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub disabled_at: Option<TimeDateTimeWithTimeZone>,
pub disabled_by: Option<i64>,
pub from_wikidot: bool,
Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ pub struct Model {
pub from_id: i64,
pub metadata: Json,
pub created_by: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
pub overwritten_by: Option<i64>,
#[serde(with = "time::serde::rfc3339::option")]
pub overwritten_at: Option<TimeDateTimeWithTimeZone>,
pub deleted_by: Option<i64>,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
}

Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub session_token: String,
pub user_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339")]
pub expires_at: TimeDateTimeWithTimeZone,
#[sea_orm(column_type = "Text")]
pub ip_address: String,
Expand Down
3 changes: 3 additions & 0 deletions deepwell/src/models/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ use serde::{Deserialize, Serialize};
pub struct Model {
#[sea_orm(primary_key)]
pub site_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
pub from_wikidot: bool,
#[sea_orm(column_type = "Text")]
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/models/site_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false, column_type = "Text")]
pub domain: String,
pub site_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
}

Expand Down
6 changes: 6 additions & 0 deletions deepwell/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ pub struct Model {
#[sea_orm(primary_key)]
pub user_id: i64,
pub user_type: UserType,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[serde(with = "time::serde::rfc3339::option")]
pub deleted_at: Option<TimeDateTimeWithTimeZone>,
pub from_wikidot: bool,
#[sea_orm(column_type = "Text")]
pub name: String,
#[sea_orm(column_type = "Text")]
pub slug: String,
pub name_changes_left: i16,
#[serde(with = "time::serde::rfc3339")]
pub last_name_change_added_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub last_renamed_at: Option<TimeDateTimeWithTimeZone>,
#[sea_orm(column_type = "Text")]
pub email: String,
pub email_is_alias: Option<bool>,
#[serde(with = "time::serde::rfc3339::option")]
pub email_verified_at: Option<TimeDateTimeWithTimeZone>,
#[sea_orm(column_type = "Text")]
pub password: String,
Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/models/user_bot_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ pub struct Model {
pub bot_user_id: i64,
#[sea_orm(primary_key, auto_increment = false)]
pub human_user_id: i64,
#[serde(with = "time::serde::rfc3339")]
pub created_at: TimeDateTimeWithTimeZone,
#[serde(with = "time::serde::rfc3339::option")]
pub updated_at: Option<TimeDateTimeWithTimeZone>,
#[sea_orm(column_type = "Text")]
pub description: String,
Expand Down

0 comments on commit 10ccba0

Please sign in to comment.