//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "audio_albums")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub title: String,
    #[sea_orm(unique)]
    pub slug: String,
    #[sea_orm(column_type = "Text", nullable)]
    pub description: Option<String>,
    pub cover_image_id: Option<String>,
    pub artist: Option<String>,
    pub release_date: Option<Date>,
    pub published: bool,
    pub uploader_id: i32,
    pub view_count: i32,
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
    pub published_at: Option<DateTimeWithTimeZone>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::audio_tracks::Entity")]
    AudioTracks,
    #[sea_orm(
        belongs_to = "super::users::Entity",
        from = "Column::UploaderId",
        to = "super::users::Column::Id",
        on_update = "Cascade",
        on_delete = "Cascade"
    )]
    Users,
}

impl Related<super::audio_tracks::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::AudioTracks.def()
    }
}

impl Related<super::users::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::Users.def()
    }
}
