use crate::{DateTimeUtc, ModelId, ModelVersionId};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

use super::ModelStatus;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "ai_model_version")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: ModelVersionId,
    pub model_id: ModelId,
    pub version: String,
    pub release_date: Option<DateTimeUtc>,
    pub change_log: Option<String>,
    pub is_default: bool,
    pub status: String,
    pub created_at: DateTimeUtc,
}

impl Model {
    pub fn status_enum(&self) -> Result<ModelStatus, &'static str> {
        self.status.parse()
    }
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
