From c9f31aef9bb443b4f6a8c04c03dae951eac13502 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Fri, 2 Jun 2023 03:39:52 -0400 Subject: [PATCH] add default values --- .../model/src/entity/abuse_user_report.rs | 2 +- .../crates/model/src/entity/access_token.rs | 2 +- .../crates/model/src/entity/ad.rs | 2 +- .../crates/model/src/entity/announcement.rs | 2 +- .../model/src/entity/announcement_read.rs | 2 +- .../crates/model/src/entity/antenna.rs | 2 +- .../crates/model/src/entity/antenna_note.rs | 2 +- .../crates/model/src/entity/app.rs | 2 +- .../model/src/entity/attestation_challenge.rs | 2 +- .../crates/model/src/entity/auth_session.rs | 2 +- .../crates/model/src/entity/blocking.rs | 2 +- .../crates/model/src/entity/channel.rs | 2 +- .../model/src/entity/channel_following.rs | 2 +- .../model/src/entity/channel_note_pining.rs | 2 +- .../crates/model/src/entity/clip.rs | 2 +- .../crates/model/src/entity/clip_note.rs | 2 +- .../crates/model/src/entity/drive_file.rs | 2 +- .../crates/model/src/entity/drive_folder.rs | 2 +- .../crates/model/src/entity/emoji.rs | 2 +- .../crates/model/src/entity/follow_request.rs | 2 +- .../crates/model/src/entity/following.rs | 2 +- .../crates/model/src/entity/gallery_like.rs | 2 +- .../crates/model/src/entity/gallery_post.rs | 2 +- .../crates/model/src/entity/hashtag.rs | 2 +- .../crates/model/src/entity/instance.rs | 2 +- .../model/src/entity/messaging_message.rs | 2 +- .../crates/model/src/entity/meta.rs | 2 +- .../crates/model/src/entity/migrations.rs | 2 +- .../crates/model/src/entity/moderation_log.rs | 2 +- .../crates/model/src/entity/muted_note.rs | 2 +- .../crates/model/src/entity/muting.rs | 2 +- .../crates/model/src/entity/newtype/mod.rs | 6 +- .../crates/model/src/entity/note.rs | 2 +- .../crates/model/src/entity/note_edit.rs | 2 +- .../crates/model/src/entity/note_favorite.rs | 2 +- .../crates/model/src/entity/note_reaction.rs | 2 +- .../model/src/entity/note_thread_muting.rs | 2 +- .../crates/model/src/entity/note_unread.rs | 2 +- .../crates/model/src/entity/note_watching.rs | 2 +- .../crates/model/src/entity/notification.rs | 2 +- .../crates/model/src/entity/page.rs | 2 +- .../crates/model/src/entity/page_like.rs | 2 +- .../src/entity/password_reset_request.rs | 2 +- .../crates/model/src/entity/poll.rs | 2 +- .../crates/model/src/entity/poll_vote.rs | 2 +- .../crates/model/src/entity/promo_note.rs | 2 +- .../crates/model/src/entity/promo_read.rs | 2 +- .../model/src/entity/registration_ticket.rs | 2 +- .../crates/model/src/entity/registry_item.rs | 2 +- .../crates/model/src/entity/relay.rs | 2 +- .../crates/model/src/entity/renote_muting.rs | 2 +- .../model/src/entity/sea_orm_active_enums.rs | 30 ++- .../crates/model/src/entity/signin.rs | 2 +- .../model/src/entity/sw_subscription.rs | 2 +- .../crates/model/src/entity/used_username.rs | 2 +- .../crates/model/src/entity/user.rs | 2 +- .../crates/model/src/entity/user_group.rs | 2 +- .../model/src/entity/user_group_invitation.rs | 2 +- .../model/src/entity/user_group_invite.rs | 2 +- .../model/src/entity/user_group_joining.rs | 2 +- .../crates/model/src/entity/user_ip.rs | 2 +- .../crates/model/src/entity/user_keypair.rs | 2 +- .../crates/model/src/entity/user_list.rs | 2 +- .../model/src/entity/user_list_joining.rs | 2 +- .../model/src/entity/user_note_pining.rs | 2 +- .../crates/model/src/entity/user_pending.rs | 2 +- .../crates/model/src/entity/user_profile.rs | 2 +- .../crates/model/src/entity/user_publickey.rs | 2 +- .../model/src/entity/user_security_key.rs | 2 +- .../crates/model/src/entity/webhook.rs | 2 +- .../native-utils/crates/model/tests/common.rs | 184 +++++++++++++----- 71 files changed, 226 insertions(+), 130 deletions(-) diff --git a/packages/backend/native-utils/crates/model/src/entity/abuse_user_report.rs b/packages/backend/native-utils/crates/model/src/entity/abuse_user_report.rs index 270837973c..24230b3949 100644 --- a/packages/backend/native-utils/crates/model/src/entity/abuse_user_report.rs +++ b/packages/backend/native-utils/crates/model/src/entity/abuse_user_report.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "abuse_user_report")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/access_token.rs b/packages/backend/native-utils/crates/model/src/entity/access_token.rs index f84971605f..dd9289224f 100644 --- a/packages/backend/native-utils/crates/model/src/entity/access_token.rs +++ b/packages/backend/native-utils/crates/model/src/entity/access_token.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "access_token")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/ad.rs b/packages/backend/native-utils/crates/model/src/entity/ad.rs index 708ed69ce7..2cf7a6fc87 100644 --- a/packages/backend/native-utils/crates/model/src/entity/ad.rs +++ b/packages/backend/native-utils/crates/model/src/entity/ad.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "ad")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/announcement.rs b/packages/backend/native-utils/crates/model/src/entity/announcement.rs index 3e9b916879..e8a2a28aa8 100644 --- a/packages/backend/native-utils/crates/model/src/entity/announcement.rs +++ b/packages/backend/native-utils/crates/model/src/entity/announcement.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "announcement")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/announcement_read.rs b/packages/backend/native-utils/crates/model/src/entity/announcement_read.rs index 7fc51d475e..53ff8d6cef 100644 --- a/packages/backend/native-utils/crates/model/src/entity/announcement_read.rs +++ b/packages/backend/native-utils/crates/model/src/entity/announcement_read.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "announcement_read")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/antenna.rs b/packages/backend/native-utils/crates/model/src/entity/antenna.rs index 0ebd1cf45b..85bdfbfeac 100644 --- a/packages/backend/native-utils/crates/model/src/entity/antenna.rs +++ b/packages/backend/native-utils/crates/model/src/entity/antenna.rs @@ -3,7 +3,7 @@ use super::{newtype, sea_orm_active_enums::AntennaSrcEnum}; use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "antenna")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/antenna_note.rs b/packages/backend/native-utils/crates/model/src/entity/antenna_note.rs index d4c850bfce..c86fb349d4 100644 --- a/packages/backend/native-utils/crates/model/src/entity/antenna_note.rs +++ b/packages/backend/native-utils/crates/model/src/entity/antenna_note.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "antenna_note")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/app.rs b/packages/backend/native-utils/crates/model/src/entity/app.rs index 3102945689..6400d0b24e 100644 --- a/packages/backend/native-utils/crates/model/src/entity/app.rs +++ b/packages/backend/native-utils/crates/model/src/entity/app.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "app")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/attestation_challenge.rs b/packages/backend/native-utils/crates/model/src/entity/attestation_challenge.rs index 135a4f1fb9..5217b2796d 100644 --- a/packages/backend/native-utils/crates/model/src/entity/attestation_challenge.rs +++ b/packages/backend/native-utils/crates/model/src/entity/attestation_challenge.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "attestation_challenge")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/auth_session.rs b/packages/backend/native-utils/crates/model/src/entity/auth_session.rs index 83aecbaa65..8ced191c3b 100644 --- a/packages/backend/native-utils/crates/model/src/entity/auth_session.rs +++ b/packages/backend/native-utils/crates/model/src/entity/auth_session.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "auth_session")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/blocking.rs b/packages/backend/native-utils/crates/model/src/entity/blocking.rs index 4667e60c68..4f326f6faa 100644 --- a/packages/backend/native-utils/crates/model/src/entity/blocking.rs +++ b/packages/backend/native-utils/crates/model/src/entity/blocking.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "blocking")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/channel.rs b/packages/backend/native-utils/crates/model/src/entity/channel.rs index 9132d9d4e1..abc79b4f57 100644 --- a/packages/backend/native-utils/crates/model/src/entity/channel.rs +++ b/packages/backend/native-utils/crates/model/src/entity/channel.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "channel")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/channel_following.rs b/packages/backend/native-utils/crates/model/src/entity/channel_following.rs index bd1b16dcee..93739459aa 100644 --- a/packages/backend/native-utils/crates/model/src/entity/channel_following.rs +++ b/packages/backend/native-utils/crates/model/src/entity/channel_following.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "channel_following")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/channel_note_pining.rs b/packages/backend/native-utils/crates/model/src/entity/channel_note_pining.rs index 2c9089ac45..50ec1ecefb 100644 --- a/packages/backend/native-utils/crates/model/src/entity/channel_note_pining.rs +++ b/packages/backend/native-utils/crates/model/src/entity/channel_note_pining.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "channel_note_pining")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/clip.rs b/packages/backend/native-utils/crates/model/src/entity/clip.rs index 209bd047e3..a51ef720ed 100644 --- a/packages/backend/native-utils/crates/model/src/entity/clip.rs +++ b/packages/backend/native-utils/crates/model/src/entity/clip.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "clip")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/clip_note.rs b/packages/backend/native-utils/crates/model/src/entity/clip_note.rs index 953c5511cb..a8bfd4564c 100644 --- a/packages/backend/native-utils/crates/model/src/entity/clip_note.rs +++ b/packages/backend/native-utils/crates/model/src/entity/clip_note.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "clip_note")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/drive_file.rs b/packages/backend/native-utils/crates/model/src/entity/drive_file.rs index abc191ba3a..7c42b98815 100644 --- a/packages/backend/native-utils/crates/model/src/entity/drive_file.rs +++ b/packages/backend/native-utils/crates/model/src/entity/drive_file.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "drive_file")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/drive_folder.rs b/packages/backend/native-utils/crates/model/src/entity/drive_folder.rs index f0b7162835..98a9f89011 100644 --- a/packages/backend/native-utils/crates/model/src/entity/drive_folder.rs +++ b/packages/backend/native-utils/crates/model/src/entity/drive_folder.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "drive_folder")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/emoji.rs b/packages/backend/native-utils/crates/model/src/entity/emoji.rs index fdb99a2c3f..00fc6184a8 100644 --- a/packages/backend/native-utils/crates/model/src/entity/emoji.rs +++ b/packages/backend/native-utils/crates/model/src/entity/emoji.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "emoji")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/follow_request.rs b/packages/backend/native-utils/crates/model/src/entity/follow_request.rs index af763baa6d..6f8b00b791 100644 --- a/packages/backend/native-utils/crates/model/src/entity/follow_request.rs +++ b/packages/backend/native-utils/crates/model/src/entity/follow_request.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "follow_request")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/following.rs b/packages/backend/native-utils/crates/model/src/entity/following.rs index 087ca270b6..641e415300 100644 --- a/packages/backend/native-utils/crates/model/src/entity/following.rs +++ b/packages/backend/native-utils/crates/model/src/entity/following.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "following")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/gallery_like.rs b/packages/backend/native-utils/crates/model/src/entity/gallery_like.rs index 186c92703d..e90dfedb36 100644 --- a/packages/backend/native-utils/crates/model/src/entity/gallery_like.rs +++ b/packages/backend/native-utils/crates/model/src/entity/gallery_like.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "gallery_like")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/gallery_post.rs b/packages/backend/native-utils/crates/model/src/entity/gallery_post.rs index 875d3af589..7e53e6bf39 100644 --- a/packages/backend/native-utils/crates/model/src/entity/gallery_post.rs +++ b/packages/backend/native-utils/crates/model/src/entity/gallery_post.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "gallery_post")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/hashtag.rs b/packages/backend/native-utils/crates/model/src/entity/hashtag.rs index 917f4ea1b0..7a8722a5fd 100644 --- a/packages/backend/native-utils/crates/model/src/entity/hashtag.rs +++ b/packages/backend/native-utils/crates/model/src/entity/hashtag.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "hashtag")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/instance.rs b/packages/backend/native-utils/crates/model/src/entity/instance.rs index 3f3af2a5d8..fc9c5bf8b4 100644 --- a/packages/backend/native-utils/crates/model/src/entity/instance.rs +++ b/packages/backend/native-utils/crates/model/src/entity/instance.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "instance")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/messaging_message.rs b/packages/backend/native-utils/crates/model/src/entity/messaging_message.rs index b66c01fc9b..8d7c7b8cc4 100644 --- a/packages/backend/native-utils/crates/model/src/entity/messaging_message.rs +++ b/packages/backend/native-utils/crates/model/src/entity/messaging_message.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "messaging_message")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/meta.rs b/packages/backend/native-utils/crates/model/src/entity/meta.rs index a97cb89c4d..2c0dc315c6 100644 --- a/packages/backend/native-utils/crates/model/src/entity/meta.rs +++ b/packages/backend/native-utils/crates/model/src/entity/meta.rs @@ -6,7 +6,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "meta")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/migrations.rs b/packages/backend/native-utils/crates/model/src/entity/migrations.rs index c03df11802..54e44f2fdb 100644 --- a/packages/backend/native-utils/crates/model/src/entity/migrations.rs +++ b/packages/backend/native-utils/crates/model/src/entity/migrations.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "migrations")] pub struct Model { #[sea_orm(primary_key)] diff --git a/packages/backend/native-utils/crates/model/src/entity/moderation_log.rs b/packages/backend/native-utils/crates/model/src/entity/moderation_log.rs index 3306853927..eb882b8964 100644 --- a/packages/backend/native-utils/crates/model/src/entity/moderation_log.rs +++ b/packages/backend/native-utils/crates/model/src/entity/moderation_log.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "moderation_log")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/muted_note.rs b/packages/backend/native-utils/crates/model/src/entity/muted_note.rs index 1740e90783..2388985497 100644 --- a/packages/backend/native-utils/crates/model/src/entity/muted_note.rs +++ b/packages/backend/native-utils/crates/model/src/entity/muted_note.rs @@ -3,7 +3,7 @@ use super::sea_orm_active_enums::MutedNoteReasonEnum; use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "muted_note")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/muting.rs b/packages/backend/native-utils/crates/model/src/entity/muting.rs index 83885034c6..7b46a0b246 100644 --- a/packages/backend/native-utils/crates/model/src/entity/muting.rs +++ b/packages/backend/native-utils/crates/model/src/entity/muting.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "muting")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/newtype/mod.rs b/packages/backend/native-utils/crates/model/src/entity/newtype/mod.rs index 45aa175409..3dc2d7553d 100644 --- a/packages/backend/native-utils/crates/model/src/entity/newtype/mod.rs +++ b/packages/backend/native-utils/crates/model/src/entity/newtype/mod.rs @@ -7,15 +7,15 @@ use serde::{Deserialize, Serialize}; use crate::impl_json_newtype; -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into, Default)] pub struct JsonKeyword(pub Vec>); impl_json_newtype!(JsonKeyword); -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into, Default)] pub struct JsonStringVec(pub Vec); impl_json_newtype!(JsonStringVec); -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into, Default)] pub struct JsonI32Vec(pub Vec); impl_json_newtype!(JsonI32Vec); diff --git a/packages/backend/native-utils/crates/model/src/entity/note.rs b/packages/backend/native-utils/crates/model/src/entity/note.rs index c2f20c11be..077841e48b 100644 --- a/packages/backend/native-utils/crates/model/src/entity/note.rs +++ b/packages/backend/native-utils/crates/model/src/entity/note.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "note")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/note_edit.rs b/packages/backend/native-utils/crates/model/src/entity/note_edit.rs index 4e8f420833..ea9b9eabd5 100644 --- a/packages/backend/native-utils/crates/model/src/entity/note_edit.rs +++ b/packages/backend/native-utils/crates/model/src/entity/note_edit.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "note_edit")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/note_favorite.rs b/packages/backend/native-utils/crates/model/src/entity/note_favorite.rs index 42f3c400f1..470ad55d26 100644 --- a/packages/backend/native-utils/crates/model/src/entity/note_favorite.rs +++ b/packages/backend/native-utils/crates/model/src/entity/note_favorite.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "note_favorite")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/note_reaction.rs b/packages/backend/native-utils/crates/model/src/entity/note_reaction.rs index c740d994f5..a4e9f490dc 100644 --- a/packages/backend/native-utils/crates/model/src/entity/note_reaction.rs +++ b/packages/backend/native-utils/crates/model/src/entity/note_reaction.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "note_reaction")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/note_thread_muting.rs b/packages/backend/native-utils/crates/model/src/entity/note_thread_muting.rs index f1dbfb5985..51688a0889 100644 --- a/packages/backend/native-utils/crates/model/src/entity/note_thread_muting.rs +++ b/packages/backend/native-utils/crates/model/src/entity/note_thread_muting.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "note_thread_muting")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/note_unread.rs b/packages/backend/native-utils/crates/model/src/entity/note_unread.rs index 7468156113..a444eb35dd 100644 --- a/packages/backend/native-utils/crates/model/src/entity/note_unread.rs +++ b/packages/backend/native-utils/crates/model/src/entity/note_unread.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "note_unread")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/note_watching.rs b/packages/backend/native-utils/crates/model/src/entity/note_watching.rs index 4a87a44950..962ef081e0 100644 --- a/packages/backend/native-utils/crates/model/src/entity/note_watching.rs +++ b/packages/backend/native-utils/crates/model/src/entity/note_watching.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "note_watching")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/notification.rs b/packages/backend/native-utils/crates/model/src/entity/notification.rs index 4500e59d9f..896b6c2da3 100644 --- a/packages/backend/native-utils/crates/model/src/entity/notification.rs +++ b/packages/backend/native-utils/crates/model/src/entity/notification.rs @@ -3,7 +3,7 @@ use super::sea_orm_active_enums::NotificationTypeEnum; use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "notification")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/page.rs b/packages/backend/native-utils/crates/model/src/entity/page.rs index c3d09fa8c2..dabb5c9f06 100644 --- a/packages/backend/native-utils/crates/model/src/entity/page.rs +++ b/packages/backend/native-utils/crates/model/src/entity/page.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "page")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/page_like.rs b/packages/backend/native-utils/crates/model/src/entity/page_like.rs index 3d3d2f3ac7..108b6b929f 100644 --- a/packages/backend/native-utils/crates/model/src/entity/page_like.rs +++ b/packages/backend/native-utils/crates/model/src/entity/page_like.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "page_like")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/password_reset_request.rs b/packages/backend/native-utils/crates/model/src/entity/password_reset_request.rs index 3b24d70d90..45cc3de107 100644 --- a/packages/backend/native-utils/crates/model/src/entity/password_reset_request.rs +++ b/packages/backend/native-utils/crates/model/src/entity/password_reset_request.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "password_reset_request")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/poll.rs b/packages/backend/native-utils/crates/model/src/entity/poll.rs index 81953cfbac..4d64594c76 100644 --- a/packages/backend/native-utils/crates/model/src/entity/poll.rs +++ b/packages/backend/native-utils/crates/model/src/entity/poll.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; use super::newtype::{I32Vec, StringVec}; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "poll")] pub struct Model { #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] diff --git a/packages/backend/native-utils/crates/model/src/entity/poll_vote.rs b/packages/backend/native-utils/crates/model/src/entity/poll_vote.rs index 1b8b3ba1c0..bf26bf5dd5 100644 --- a/packages/backend/native-utils/crates/model/src/entity/poll_vote.rs +++ b/packages/backend/native-utils/crates/model/src/entity/poll_vote.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "poll_vote")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/promo_note.rs b/packages/backend/native-utils/crates/model/src/entity/promo_note.rs index aa5eb2f3d1..288a0ea812 100644 --- a/packages/backend/native-utils/crates/model/src/entity/promo_note.rs +++ b/packages/backend/native-utils/crates/model/src/entity/promo_note.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "promo_note")] pub struct Model { #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] diff --git a/packages/backend/native-utils/crates/model/src/entity/promo_read.rs b/packages/backend/native-utils/crates/model/src/entity/promo_read.rs index d7dcacfb87..4e6224cf29 100644 --- a/packages/backend/native-utils/crates/model/src/entity/promo_read.rs +++ b/packages/backend/native-utils/crates/model/src/entity/promo_read.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "promo_read")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/registration_ticket.rs b/packages/backend/native-utils/crates/model/src/entity/registration_ticket.rs index f71c87327b..798f19586f 100644 --- a/packages/backend/native-utils/crates/model/src/entity/registration_ticket.rs +++ b/packages/backend/native-utils/crates/model/src/entity/registration_ticket.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "registration_ticket")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/registry_item.rs b/packages/backend/native-utils/crates/model/src/entity/registry_item.rs index 54d72d5d89..904c43abfe 100644 --- a/packages/backend/native-utils/crates/model/src/entity/registry_item.rs +++ b/packages/backend/native-utils/crates/model/src/entity/registry_item.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "registry_item")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/relay.rs b/packages/backend/native-utils/crates/model/src/entity/relay.rs index 736b48b780..bed89c849f 100644 --- a/packages/backend/native-utils/crates/model/src/entity/relay.rs +++ b/packages/backend/native-utils/crates/model/src/entity/relay.rs @@ -3,7 +3,7 @@ use super::sea_orm_active_enums::RelayStatusEnum; use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "relay")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/renote_muting.rs b/packages/backend/native-utils/crates/model/src/entity/renote_muting.rs index b5e7d38f24..44751c14c5 100644 --- a/packages/backend/native-utils/crates/model/src/entity/renote_muting.rs +++ b/packages/backend/native-utils/crates/model/src/entity/renote_muting.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "renote_muting")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/sea_orm_active_enums.rs b/packages/backend/native-utils/crates/model/src/entity/sea_orm_active_enums.rs index 14ef7002a2..f269952246 100644 --- a/packages/backend/native-utils/crates/model/src/entity/sea_orm_active_enums.rs +++ b/packages/backend/native-utils/crates/model/src/entity/sea_orm_active_enums.rs @@ -2,9 +2,10 @@ use sea_orm::entity::prelude::*; -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")] pub enum AntennaSrcEnum { + #[default] #[sea_orm(string_value = "all")] All, #[sea_orm(string_value = "group")] @@ -18,13 +19,14 @@ pub enum AntennaSrcEnum { #[sea_orm(string_value = "users")] Users, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", enum_name = "meta_sensitivemediadetection_enum" )] pub enum MetaSensitivemediadetectionEnum { + #[default] #[sea_orm(string_value = "all")] All, #[sea_orm(string_value = "local")] @@ -34,7 +36,7 @@ pub enum MetaSensitivemediadetectionEnum { #[sea_orm(string_value = "remote")] Remote, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -45,6 +47,7 @@ pub enum MetaSensitivemediadetectionsensitivityEnum { High, #[sea_orm(string_value = "low")] Low, + #[default] #[sea_orm(string_value = "medium")] Medium, #[sea_orm(string_value = "veryHigh")] @@ -52,13 +55,14 @@ pub enum MetaSensitivemediadetectionsensitivityEnum { #[sea_orm(string_value = "veryLow")] VeryLow, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", enum_name = "muted_note_reason_enum" )] pub enum MutedNoteReasonEnum { + #[default] #[sea_orm(string_value = "manual")] Manual, #[sea_orm(string_value = "other")] @@ -68,7 +72,7 @@ pub enum MutedNoteReasonEnum { #[sea_orm(string_value = "word")] Word, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -81,12 +85,13 @@ pub enum NoteVisibilityEnum { Hidden, #[sea_orm(string_value = "home")] Home, + #[default] #[sea_orm(string_value = "public")] Public, #[sea_orm(string_value = "specified")] Specified, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -115,10 +120,11 @@ pub enum NotificationTypeEnum { ReceiveFollowRequest, #[sea_orm(string_value = "renote")] Renote, + #[default] #[sea_orm(string_value = "reply")] Reply, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -127,12 +133,13 @@ pub enum NotificationTypeEnum { pub enum PageVisibilityEnum { #[sea_orm(string_value = "followers")] Followers, + #[default] #[sea_orm(string_value = "public")] Public, #[sea_orm(string_value = "specified")] Specified, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -143,22 +150,24 @@ pub enum PollNotevisibilityEnum { Followers, #[sea_orm(string_value = "home")] Home, + #[default] #[sea_orm(string_value = "public")] Public, #[sea_orm(string_value = "specified")] Specified, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")] pub enum RelayStatusEnum { #[sea_orm(string_value = "accepted")] Accepted, #[sea_orm(string_value = "rejected")] Rejected, + #[default] #[sea_orm(string_value = "requesting")] Requesting, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -169,6 +178,7 @@ pub enum UserProfileFfvisibilityEnum { Followers, #[sea_orm(string_value = "private")] Private, + #[default] #[sea_orm(string_value = "public")] Public, } diff --git a/packages/backend/native-utils/crates/model/src/entity/signin.rs b/packages/backend/native-utils/crates/model/src/entity/signin.rs index 6220973c11..60bbc33d20 100644 --- a/packages/backend/native-utils/crates/model/src/entity/signin.rs +++ b/packages/backend/native-utils/crates/model/src/entity/signin.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "signin")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/sw_subscription.rs b/packages/backend/native-utils/crates/model/src/entity/sw_subscription.rs index eaa332d8c6..1be9e046a0 100644 --- a/packages/backend/native-utils/crates/model/src/entity/sw_subscription.rs +++ b/packages/backend/native-utils/crates/model/src/entity/sw_subscription.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "sw_subscription")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/used_username.rs b/packages/backend/native-utils/crates/model/src/entity/used_username.rs index e9e8eb0978..620950b643 100644 --- a/packages/backend/native-utils/crates/model/src/entity/used_username.rs +++ b/packages/backend/native-utils/crates/model/src/entity/used_username.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "used_username")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user.rs b/packages/backend/native-utils/crates/model/src/entity/user.rs index 1cf6ac6b7b..f30fd8ace8 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group.rs b/packages/backend/native-utils/crates/model/src/entity/user_group.rs index 680f78b9ed..74ee4f22fb 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_group.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_group.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_group")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group_invitation.rs b/packages/backend/native-utils/crates/model/src/entity/user_group_invitation.rs index 5a6f6f4a16..baa6fea83e 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_group_invitation.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_group_invitation.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_group_invitation")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group_invite.rs b/packages/backend/native-utils/crates/model/src/entity/user_group_invite.rs index 786dd1f315..dbbc055f01 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_group_invite.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_group_invite.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_group_invite")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group_joining.rs b/packages/backend/native-utils/crates/model/src/entity/user_group_joining.rs index 2baa0b9a72..e7741520cd 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_group_joining.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_group_joining.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_group_joining")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_ip.rs b/packages/backend/native-utils/crates/model/src/entity/user_ip.rs index 872cfd860e..ce0af264d9 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_ip.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_ip.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_ip")] pub struct Model { #[sea_orm(primary_key)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_keypair.rs b/packages/backend/native-utils/crates/model/src/entity/user_keypair.rs index df23b506b3..0382d5d768 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_keypair.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_keypair.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_keypair")] pub struct Model { #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_list.rs b/packages/backend/native-utils/crates/model/src/entity/user_list.rs index ff05f2c440..7cc972133a 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_list.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_list.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_list")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_list_joining.rs b/packages/backend/native-utils/crates/model/src/entity/user_list_joining.rs index 27899a8c5f..4f28a21dba 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_list_joining.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_list_joining.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_list_joining")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_note_pining.rs b/packages/backend/native-utils/crates/model/src/entity/user_note_pining.rs index bcb3ec8b02..e657fcb532 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_note_pining.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_note_pining.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_note_pining")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_pending.rs b/packages/backend/native-utils/crates/model/src/entity/user_pending.rs index 1fb3b4fdcf..297fe553cc 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_pending.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_pending.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_pending")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_profile.rs b/packages/backend/native-utils/crates/model/src/entity/user_profile.rs index d62607f162..4c2f903d4b 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_profile.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_profile.rs @@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_profile")] pub struct Model { #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_publickey.rs b/packages/backend/native-utils/crates/model/src/entity/user_publickey.rs index c3c6dbf1f0..b1f426c5b0 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_publickey.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_publickey.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_publickey")] pub struct Model { #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] diff --git a/packages/backend/native-utils/crates/model/src/entity/user_security_key.rs b/packages/backend/native-utils/crates/model/src/entity/user_security_key.rs index cbb31e1b0d..4bc9763365 100644 --- a/packages/backend/native-utils/crates/model/src/entity/user_security_key.rs +++ b/packages/backend/native-utils/crates/model/src/entity/user_security_key.rs @@ -2,7 +2,7 @@ use sea_orm::entity::prelude::*; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "user_security_key")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/src/entity/webhook.rs b/packages/backend/native-utils/crates/model/src/entity/webhook.rs index dd3c3c7389..06ea1516b3 100644 --- a/packages/backend/native-utils/crates/model/src/entity/webhook.rs +++ b/packages/backend/native-utils/crates/model/src/entity/webhook.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; use super::newtype::StringVec; -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)] #[sea_orm(table_name = "webhook")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] diff --git a/packages/backend/native-utils/crates/model/tests/common.rs b/packages/backend/native-utils/crates/model/tests/common.rs index 0fd32d8f96..add8c12b24 100644 --- a/packages/backend/native-utils/crates/model/tests/common.rs +++ b/packages/backend/native-utils/crates/model/tests/common.rs @@ -3,12 +3,12 @@ extern crate model; mod repository; use chrono::Utc; -use model::entity::{antenna, sea_orm_active_enums::AntennaSrcEnum, user}; +use model::entity; +use model::entity::sea_orm_active_enums::AntennaSrcEnum; use sea_orm::{ - ActiveModelTrait, ActiveValue::Set, ConnectionTrait, DbBackend, DbConn, DbErr, EntityTrait, - TransactionTrait, + sea_query::TableCreateStatement, ActiveModelTrait, ConnectionTrait, DbBackend, DbConn, DbErr, + EntityTrait, IntoActiveModel, TransactionTrait, }; -use std::env; use util::{ id::{create_id, init_id}, random::gen_string, @@ -16,31 +16,119 @@ use util::{ /// Insert predefined entries in the database. async fn prepare() { - let conn_uri = env::var("DATABASE_URL") - .unwrap_or("postgres://calckey:calckey@localhost/calckey".to_string()); - database::init_database(conn_uri) + database::init_database("sqlite::memory:") .await .expect("Unable to initialize database connection"); let db = database::get_database().expect("Unable to get database connection from pool"); + setup_schema(db).await; setup_model(db).await; } -async fn setup_schema(db: DbConn) { - // Setup Schema helper +/// Setup schemas in the database. +async fn setup_schema(db: &DbConn) { let schema = sea_orm::Schema::new(DbBackend::Sqlite); - let stmt = schema.create_table_from_entity(antenna::Entity); - db.execute(db.get_database_backend().build(&stmt)) - .await - .expect("Unable to setup schemas for in-memoty sqlite"); + let mut stmts: Vec = Vec::new(); + macro_rules! create_table_statement { + ($a:tt) => { + stmts.push(schema.create_table_from_entity(entity::$a::Entity).if_not_exists().to_owned()); + }; + ($a:tt, $($b:tt),+) => { + create_table_statement!($a); + create_table_statement!($($b),+); + }; + } + create_table_statement!( + abuse_user_report, + access_token, + ad, + announcement_read, + announcement, + antenna_note, + antenna, + app, + attestation_challenge, + auth_session, + blocking, + channel_following, + channel_note_pining, + channel, + clip_note, + clip, + drive_file, + drive_folder, + emoji, + following, + follow_request, + gallery_like, + gallery_post, + hashtag, + instance, + messaging_message, + meta, + migrations, + moderation_log, + muted_note, + muting, + note_edit, + note_favorite, + note_reaction, + note, + note_thread_muting, + note_unread, + note_watching, + notification, + page_like, + page, + password_reset_request, + poll, + poll_vote, + promo_note, + promo_read, + registration_ticket, + registry_item, + relay, + renote_muting, + signin, + sw_subscription, + used_username, + user_group_invitation, + user_group_invite, + user_group_joining, + user_group, + user_ip, + user_keypair, + user_list_joining, + user_list, + user_note_pining, + user_pending, + user_profile, + user_publickey, + user, + user_security_key, + webhook + ); + db.transaction::<_, (), DbErr>(|txn| { + Box::pin(async move { + for stmt in stmts { + txn.execute(txn.get_database_backend().build(&stmt)).await?; + } + Ok(()) + }) + }) + .await + .expect("Unable to setup schemas"); } /// Delete all entries in the database. async fn cleanup() { - let db = database::get_database().unwrap(); + let db = database::get_database().expect("Unable to get database connection from pool"); db.transaction::<_, (), DbErr>(|txn| { Box::pin(async move { - user::Entity::delete_many().exec(txn).await.unwrap(); - antenna::Entity::delete_many().exec(txn).await.unwrap(); + entity::user::Entity::delete_many().exec(txn).await.unwrap(); + entity::antenna::Entity::delete_many() + .exec(txn) + .await + .unwrap(); Ok(()) }) @@ -56,40 +144,46 @@ async fn setup_model(db: &DbConn) { Box::pin(async move { let user_id = create_id().unwrap(); let name = "Alice"; - let user_model = user::ActiveModel { - id: Set(user_id.to_owned()), - created_at: Set(Utc::now().into()), - username: Set(name.to_lowercase().to_string()), - username_lower: Set(name.to_lowercase().to_string()), - name: Set(Some(name.to_string())), - token: Set(Some(gen_string(16))), - is_admin: Set(true), + let user_model = entity::user::Model { + id: user_id.to_owned(), + created_at: Utc::now().into(), + username: name.to_lowercase().to_string(), + username_lower: name.to_lowercase().to_string(), + name: Some(name.to_string()), + token: Some(gen_string(16)), + is_admin: true, ..Default::default() }; - user_model.insert(txn).await?; - let antenna_model = antenna::ActiveModel { - id: Set(create_id().unwrap()), - created_at: Set(Utc::now().into()), - user_id: Set(user_id.to_owned()), - name: Set("Test Antenna".to_string()), - src: Set(AntennaSrcEnum::All), - keywords: Set(vec![ + user_model + .into_active_model() + .reset_all() + .insert(txn) + .await?; + let antenna_model = entity::antenna::Model { + id: create_id().unwrap(), + created_at: Utc::now().into(), + user_id: user_id.to_owned(), + name: "Test Antenna".to_string(), + src: AntennaSrcEnum::All, + keywords: vec![ vec!["foo".to_string(), "bar".to_string()], vec!["foobar".to_string()], ] - .into()), - exclude_keywords: Set(vec![ + .into(), + exclude_keywords: vec![ vec!["abc".to_string()], vec!["def".to_string(), "ghi".to_string()], ] - .into()), - with_file: Set(false), - notify: Set(true), - case_sensitive: Set(true), - with_replies: Set(false), + .into(), + notify: true, + case_sensitive: true, ..Default::default() }; - antenna_model.insert(txn).await?; + antenna_model + .into_active_model() + .reset_all() + .insert(txn) + .await?; Ok(()) }) @@ -99,19 +193,11 @@ async fn setup_model(db: &DbConn) { } mod int_test { - use sea_orm::Database; - - use super::{cleanup, prepare, setup_schema}; + use super::{cleanup, prepare}; #[tokio::test] async fn can_prepare_and_cleanup() { prepare().await; cleanup().await; } - - #[tokio::test] - async fn can_setup_sqlite_schema() { - let db = Database::connect("sqlite::memory:").await.unwrap(); - setup_schema(db).await; - } }