add default values
This commit is contained in:
parent
3eb87c8f04
commit
c9f31aef9b
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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<Vec<String>>);
|
||||
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<String>);
|
||||
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<i32>);
|
||||
impl_json_newtype!(JsonI32Vec);
|
||||
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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))
|
||||
let mut stmts: Vec<TableCreateStatement> = 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 for in-memoty sqlite");
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue