//! `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_track_tags")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub track_id: Uuid,
    #[sea_orm(primary_key, auto_increment = false)]
    pub tag_id: Uuid,
    pub created_at: DateTimeWithTimeZone,
}

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

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

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