The first completed version!

This commit is contained in:
Shiroyasha 2025-01-08 18:22:57 +03:00
parent 2844bb9149
commit 42fd8f571e
Signed by: shiroyashik
GPG key ID: E4953D3940D7860A
37 changed files with 2320 additions and 952 deletions

33
database/src/actions.rs Normal file
View file

@ -0,0 +1,33 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "actions")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub rid: i32,
pub uid: i64,
pub created_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::requests::Entity",
from = "Column::Rid",
to = "super::requests::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Requests,
}
impl Related<super::requests::Entity> for Entity {
fn to() -> RelationDef {
Relation::Requests.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

35
database/src/archived.rs Normal file
View file

@ -0,0 +1,35 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "archived")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub ytid: String,
pub viewed_at: Option<DateTime>,
pub created_by: i64,
pub created_at: DateTime,
pub contributors: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::videos::Entity",
from = "Column::Ytid",
to = "super::videos::Column::Ytid",
on_update = "NoAction",
on_delete = "NoAction"
)]
Videos,
}
impl Related<super::videos::Entity> for Entity {
fn to() -> RelationDef {
Relation::Videos.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

10
database/src/lib.rs Normal file
View file

@ -0,0 +1,10 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
pub mod prelude;
pub mod actions;
pub mod archived;
pub mod moderators;
pub mod requests;
pub mod users;
pub mod videos;

View file

@ -0,0 +1,18 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "moderators")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: i64,
pub created_at: DateTime,
pub notify: bool,
pub can_add_mods: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

8
database/src/prelude.rs Normal file
View file

@ -0,0 +1,8 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
pub use super::actions::Entity as Actions;
pub use super::archived::Entity as Archived;
pub use super::moderators::Entity as Moderators;
pub use super::requests::Entity as Requests;
pub use super::users::Entity as Users;
pub use super::videos::Entity as Videos;

40
database/src/requests.rs Normal file
View file

@ -0,0 +1,40 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "requests")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub ytid: String,
pub viewed_at: Option<DateTime>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::actions::Entity")]
Actions,
#[sea_orm(
belongs_to = "super::videos::Entity",
from = "Column::Ytid",
to = "super::videos::Column::Ytid",
on_update = "NoAction",
on_delete = "Cascade"
)]
Videos,
}
impl Related<super::actions::Entity> for Entity {
fn to() -> RelationDef {
Relation::Actions.def()
}
}
impl Related<super::videos::Entity> for Entity {
fn to() -> RelationDef {
Relation::Videos.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

17
database/src/users.rs Normal file
View file

@ -0,0 +1,17 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "users")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: i64,
pub created_at: DateTime,
pub contributions: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

34
database/src/videos.rs Normal file
View file

@ -0,0 +1,34 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "videos")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub ytid: String,
pub title: String,
pub banned: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::archived::Entity")]
Archived,
#[sea_orm(has_many = "super::requests::Entity")]
Requests,
}
impl Related<super::archived::Entity> for Entity {
fn to() -> RelationDef {
Relation::Archived.def()
}
}
impl Related<super::requests::Entity> for Entity {
fn to() -> RelationDef {
Relation::Requests.def()
}
}
impl ActiveModelBehavior for ActiveModel {}