add default values

This commit is contained in:
Namekuji 2023-06-02 03:39:52 -04:00
parent 3eb87c8f04
commit c9f31aef9b
No known key found for this signature in database
GPG key ID: B541BD6E646CABC7
71 changed files with 226 additions and 130 deletions

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "abuse_user_report")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "access_token")] #[sea_orm(table_name = "access_token")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "ad")] #[sea_orm(table_name = "ad")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "announcement")] #[sea_orm(table_name = "announcement")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "announcement_read")] #[sea_orm(table_name = "announcement_read")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -3,7 +3,7 @@
use super::{newtype, sea_orm_active_enums::AntennaSrcEnum}; use super::{newtype, sea_orm_active_enums::AntennaSrcEnum};
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "antenna")] #[sea_orm(table_name = "antenna")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "antenna_note")] #[sea_orm(table_name = "antenna_note")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "app")] #[sea_orm(table_name = "app")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "attestation_challenge")] #[sea_orm(table_name = "attestation_challenge")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "auth_session")] #[sea_orm(table_name = "auth_session")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "blocking")] #[sea_orm(table_name = "blocking")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "channel")] #[sea_orm(table_name = "channel")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "channel_following")] #[sea_orm(table_name = "channel_following")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "channel_note_pining")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "clip")] #[sea_orm(table_name = "clip")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "clip_note")] #[sea_orm(table_name = "clip_note")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "drive_file")] #[sea_orm(table_name = "drive_file")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "drive_folder")] #[sea_orm(table_name = "drive_folder")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "emoji")] #[sea_orm(table_name = "emoji")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "follow_request")] #[sea_orm(table_name = "follow_request")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "following")] #[sea_orm(table_name = "following")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "gallery_like")] #[sea_orm(table_name = "gallery_like")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "gallery_post")] #[sea_orm(table_name = "gallery_post")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "hashtag")] #[sea_orm(table_name = "hashtag")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "instance")] #[sea_orm(table_name = "instance")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "messaging_message")] #[sea_orm(table_name = "messaging_message")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -6,7 +6,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "meta")] #[sea_orm(table_name = "meta")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "migrations")] #[sea_orm(table_name = "migrations")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "moderation_log")] #[sea_orm(table_name = "moderation_log")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -3,7 +3,7 @@
use super::sea_orm_active_enums::MutedNoteReasonEnum; use super::sea_orm_active_enums::MutedNoteReasonEnum;
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "muted_note")] #[sea_orm(table_name = "muted_note")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "muting")] #[sea_orm(table_name = "muting")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -7,15 +7,15 @@ use serde::{Deserialize, Serialize};
use crate::impl_json_newtype; 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>>); pub struct JsonKeyword(pub Vec<Vec<String>>);
impl_json_newtype!(JsonKeyword); 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>); pub struct JsonStringVec(pub Vec<String>);
impl_json_newtype!(JsonStringVec); 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>); pub struct JsonI32Vec(pub Vec<i32>);
impl_json_newtype!(JsonI32Vec); impl_json_newtype!(JsonI32Vec);

View file

@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "note")] #[sea_orm(table_name = "note")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "note_edit")] #[sea_orm(table_name = "note_edit")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "note_favorite")] #[sea_orm(table_name = "note_favorite")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "note_reaction")] #[sea_orm(table_name = "note_reaction")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "note_thread_muting")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "note_unread")] #[sea_orm(table_name = "note_unread")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "note_watching")] #[sea_orm(table_name = "note_watching")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -3,7 +3,7 @@
use super::sea_orm_active_enums::NotificationTypeEnum; use super::sea_orm_active_enums::NotificationTypeEnum;
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "notification")] #[sea_orm(table_name = "notification")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "page")] #[sea_orm(table_name = "page")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "page_like")] #[sea_orm(table_name = "page_like")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "password_reset_request")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::{I32Vec, StringVec}; use super::newtype::{I32Vec, StringVec};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "poll")] #[sea_orm(table_name = "poll")]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "poll_vote")] #[sea_orm(table_name = "poll_vote")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "promo_note")] #[sea_orm(table_name = "promo_note")]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "promo_read")] #[sea_orm(table_name = "promo_read")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "registration_ticket")] #[sea_orm(table_name = "registration_ticket")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "registry_item")] #[sea_orm(table_name = "registry_item")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -3,7 +3,7 @@
use super::sea_orm_active_enums::RelayStatusEnum; use super::sea_orm_active_enums::RelayStatusEnum;
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "relay")] #[sea_orm(table_name = "relay")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "renote_muting")] #[sea_orm(table_name = "renote_muting")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,9 +2,10 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")]
pub enum AntennaSrcEnum { pub enum AntennaSrcEnum {
#[default]
#[sea_orm(string_value = "all")] #[sea_orm(string_value = "all")]
All, All,
#[sea_orm(string_value = "group")] #[sea_orm(string_value = "group")]
@ -18,13 +19,14 @@ pub enum AntennaSrcEnum {
#[sea_orm(string_value = "users")] #[sea_orm(string_value = "users")]
Users, Users,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
enum_name = "meta_sensitivemediadetection_enum" enum_name = "meta_sensitivemediadetection_enum"
)] )]
pub enum MetaSensitivemediadetectionEnum { pub enum MetaSensitivemediadetectionEnum {
#[default]
#[sea_orm(string_value = "all")] #[sea_orm(string_value = "all")]
All, All,
#[sea_orm(string_value = "local")] #[sea_orm(string_value = "local")]
@ -34,7 +36,7 @@ pub enum MetaSensitivemediadetectionEnum {
#[sea_orm(string_value = "remote")] #[sea_orm(string_value = "remote")]
Remote, Remote,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -45,6 +47,7 @@ pub enum MetaSensitivemediadetectionsensitivityEnum {
High, High,
#[sea_orm(string_value = "low")] #[sea_orm(string_value = "low")]
Low, Low,
#[default]
#[sea_orm(string_value = "medium")] #[sea_orm(string_value = "medium")]
Medium, Medium,
#[sea_orm(string_value = "veryHigh")] #[sea_orm(string_value = "veryHigh")]
@ -52,13 +55,14 @@ pub enum MetaSensitivemediadetectionsensitivityEnum {
#[sea_orm(string_value = "veryLow")] #[sea_orm(string_value = "veryLow")]
VeryLow, VeryLow,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
enum_name = "muted_note_reason_enum" enum_name = "muted_note_reason_enum"
)] )]
pub enum MutedNoteReasonEnum { pub enum MutedNoteReasonEnum {
#[default]
#[sea_orm(string_value = "manual")] #[sea_orm(string_value = "manual")]
Manual, Manual,
#[sea_orm(string_value = "other")] #[sea_orm(string_value = "other")]
@ -68,7 +72,7 @@ pub enum MutedNoteReasonEnum {
#[sea_orm(string_value = "word")] #[sea_orm(string_value = "word")]
Word, Word,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -81,12 +85,13 @@ pub enum NoteVisibilityEnum {
Hidden, Hidden,
#[sea_orm(string_value = "home")] #[sea_orm(string_value = "home")]
Home, Home,
#[default]
#[sea_orm(string_value = "public")] #[sea_orm(string_value = "public")]
Public, Public,
#[sea_orm(string_value = "specified")] #[sea_orm(string_value = "specified")]
Specified, Specified,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -115,10 +120,11 @@ pub enum NotificationTypeEnum {
ReceiveFollowRequest, ReceiveFollowRequest,
#[sea_orm(string_value = "renote")] #[sea_orm(string_value = "renote")]
Renote, Renote,
#[default]
#[sea_orm(string_value = "reply")] #[sea_orm(string_value = "reply")]
Reply, Reply,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -127,12 +133,13 @@ pub enum NotificationTypeEnum {
pub enum PageVisibilityEnum { pub enum PageVisibilityEnum {
#[sea_orm(string_value = "followers")] #[sea_orm(string_value = "followers")]
Followers, Followers,
#[default]
#[sea_orm(string_value = "public")] #[sea_orm(string_value = "public")]
Public, Public,
#[sea_orm(string_value = "specified")] #[sea_orm(string_value = "specified")]
Specified, Specified,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -143,22 +150,24 @@ pub enum PollNotevisibilityEnum {
Followers, Followers,
#[sea_orm(string_value = "home")] #[sea_orm(string_value = "home")]
Home, Home,
#[default]
#[sea_orm(string_value = "public")] #[sea_orm(string_value = "public")]
Public, Public,
#[sea_orm(string_value = "specified")] #[sea_orm(string_value = "specified")]
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")] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")]
pub enum RelayStatusEnum { pub enum RelayStatusEnum {
#[sea_orm(string_value = "accepted")] #[sea_orm(string_value = "accepted")]
Accepted, Accepted,
#[sea_orm(string_value = "rejected")] #[sea_orm(string_value = "rejected")]
Rejected, Rejected,
#[default]
#[sea_orm(string_value = "requesting")] #[sea_orm(string_value = "requesting")]
Requesting, Requesting,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -169,6 +178,7 @@ pub enum UserProfileFfvisibilityEnum {
Followers, Followers,
#[sea_orm(string_value = "private")] #[sea_orm(string_value = "private")]
Private, Private,
#[default]
#[sea_orm(string_value = "public")] #[sea_orm(string_value = "public")]
Public, Public,
} }

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "signin")] #[sea_orm(table_name = "signin")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "sw_subscription")] #[sea_orm(table_name = "sw_subscription")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "used_username")] #[sea_orm(table_name = "used_username")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user")] #[sea_orm(table_name = "user")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_group")] #[sea_orm(table_name = "user_group")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "user_group_invitation")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "user_group_invite")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "user_group_joining")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_ip")] #[sea_orm(table_name = "user_ip")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_keypair")] #[sea_orm(table_name = "user_keypair")]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_list")] #[sea_orm(table_name = "user_list")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "user_list_joining")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "user_note_pining")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_pending")] #[sea_orm(table_name = "user_pending")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -5,7 +5,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_profile")] #[sea_orm(table_name = "user_profile")]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_publickey")] #[sea_orm(table_name = "user_publickey")]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]

View file

@ -2,7 +2,7 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(table_name = "user_security_key")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*;
use super::newtype::StringVec; use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "webhook")] #[sea_orm(table_name = "webhook")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]

View file

@ -3,12 +3,12 @@ extern crate model;
mod repository; mod repository;
use chrono::Utc; 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::{ use sea_orm::{
ActiveModelTrait, ActiveValue::Set, ConnectionTrait, DbBackend, DbConn, DbErr, EntityTrait, sea_query::TableCreateStatement, ActiveModelTrait, ConnectionTrait, DbBackend, DbConn, DbErr,
TransactionTrait, EntityTrait, IntoActiveModel, TransactionTrait,
}; };
use std::env;
use util::{ use util::{
id::{create_id, init_id}, id::{create_id, init_id},
random::gen_string, random::gen_string,
@ -16,31 +16,119 @@ use util::{
/// Insert predefined entries in the database. /// Insert predefined entries in the database.
async fn prepare() { async fn prepare() {
let conn_uri = env::var("DATABASE_URL") database::init_database("sqlite::memory:")
.unwrap_or("postgres://calckey:calckey@localhost/calckey".to_string());
database::init_database(conn_uri)
.await .await
.expect("Unable to initialize database connection"); .expect("Unable to initialize database connection");
let db = database::get_database().expect("Unable to get database connection from pool"); let db = database::get_database().expect("Unable to get database connection from pool");
setup_schema(db).await;
setup_model(db).await; setup_model(db).await;
} }
async fn setup_schema(db: DbConn) { /// Setup schemas in the database.
// Setup Schema helper async fn setup_schema(db: &DbConn) {
let schema = sea_orm::Schema::new(DbBackend::Sqlite); let schema = sea_orm::Schema::new(DbBackend::Sqlite);
let stmt = schema.create_table_from_entity(antenna::Entity); let mut stmts: Vec<TableCreateStatement> = Vec::new();
db.execute(db.get_database_backend().build(&stmt)) macro_rules! create_table_statement {
.await ($a:tt) => {
.expect("Unable to setup schemas for in-memoty sqlite"); 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. /// Delete all entries in the database.
async fn cleanup() { 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| { db.transaction::<_, (), DbErr>(|txn| {
Box::pin(async move { Box::pin(async move {
user::Entity::delete_many().exec(txn).await.unwrap(); entity::user::Entity::delete_many().exec(txn).await.unwrap();
antenna::Entity::delete_many().exec(txn).await.unwrap(); entity::antenna::Entity::delete_many()
.exec(txn)
.await
.unwrap();
Ok(()) Ok(())
}) })
@ -56,40 +144,46 @@ async fn setup_model(db: &DbConn) {
Box::pin(async move { Box::pin(async move {
let user_id = create_id().unwrap(); let user_id = create_id().unwrap();
let name = "Alice"; let name = "Alice";
let user_model = user::ActiveModel { let user_model = entity::user::Model {
id: Set(user_id.to_owned()), id: user_id.to_owned(),
created_at: Set(Utc::now().into()), created_at: Utc::now().into(),
username: Set(name.to_lowercase().to_string()), username: name.to_lowercase().to_string(),
username_lower: Set(name.to_lowercase().to_string()), username_lower: name.to_lowercase().to_string(),
name: Set(Some(name.to_string())), name: Some(name.to_string()),
token: Set(Some(gen_string(16))), token: Some(gen_string(16)),
is_admin: Set(true), is_admin: true,
..Default::default() ..Default::default()
}; };
user_model.insert(txn).await?; user_model
let antenna_model = antenna::ActiveModel { .into_active_model()
id: Set(create_id().unwrap()), .reset_all()
created_at: Set(Utc::now().into()), .insert(txn)
user_id: Set(user_id.to_owned()), .await?;
name: Set("Test Antenna".to_string()), let antenna_model = entity::antenna::Model {
src: Set(AntennaSrcEnum::All), id: create_id().unwrap(),
keywords: Set(vec![ 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!["foo".to_string(), "bar".to_string()],
vec!["foobar".to_string()], vec!["foobar".to_string()],
] ]
.into()), .into(),
exclude_keywords: Set(vec![ exclude_keywords: vec![
vec!["abc".to_string()], vec!["abc".to_string()],
vec!["def".to_string(), "ghi".to_string()], vec!["def".to_string(), "ghi".to_string()],
] ]
.into()), .into(),
with_file: Set(false), notify: true,
notify: Set(true), case_sensitive: true,
case_sensitive: Set(true),
with_replies: Set(false),
..Default::default() ..Default::default()
}; };
antenna_model.insert(txn).await?; antenna_model
.into_active_model()
.reset_all()
.insert(txn)
.await?;
Ok(()) Ok(())
}) })
@ -99,19 +193,11 @@ async fn setup_model(db: &DbConn) {
} }
mod int_test { mod int_test {
use sea_orm::Database; use super::{cleanup, prepare};
use super::{cleanup, prepare, setup_schema};
#[tokio::test] #[tokio::test]
async fn can_prepare_and_cleanup() { async fn can_prepare_and_cleanup() {
prepare().await; prepare().await;
cleanup().await; cleanup().await;
} }
#[tokio::test]
async fn can_setup_sqlite_schema() {
let db = Database::connect("sqlite::memory:").await.unwrap();
setup_schema(db).await;
}
} }