/*
 * Copyright(c) 2024-2026 China Telecom Cloud Technologies Co., Ltd. All rights
 * reserved. ctscat is licensed under Mulan PSL v2. You can use this software
 * according to the terms and conditions of the Mulan PSL V2. You may obtain a
 * copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  See the Mulan PSL v2 for
 * more details.
 */

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

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

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "commit_files")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub commit_record_id: i32,
    pub filename: String,
    #[sea_orm(column_type = "Text")]
    pub file_path: String,
    pub change_type: String,
    pub additions: i32,
    pub deletions: i32,
    #[sea_orm(column_type = "Text", nullable)]
    pub patch_url: Option<String>,
    pub is_spec: bool,
    pub is_patch: bool,
    pub created_at: DateTimeUtc,
    #[sea_orm(column_type = "Text", nullable)]
    pub patch_content: Option<String>,
    pub patch_format: Option<String>,
    pub is_binary: bool,
    pub old_mode: Option<String>,
    pub new_mode: Option<String>,
    pub updated_at: Option<DateTimeUtc>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::l1_commit_records::Entity",
        from = "Column::CommitRecordId",
        to = "super::l1_commit_records::Column::Id",
        on_update = "NoAction",
        on_delete = "Cascade"
    )]
    CommitRecords,
}

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

impl ActiveModelBehavior for ActiveModel {}