194c44c
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
Default,
EnumIter,
DeriveActiveEnum,
Serialize,
Deserialize,
utoipa::ToSchema,
)]
#[serde(rename_all = "snake_case")]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum CiSecretScope {
#[default]
#[sea_orm(num_value = 0)]
Repo,
#[sea_orm(num_value = 1)]
Space,
#[sea_orm(num_value = 2)]
Environment,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "ci_secret")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub scope: CiSecretScope,
pub repo_id: Option<Uuid>,
pub space_id: Option<Uuid>,
pub environment_id: Option<Uuid>,
pub name: String,
pub value_ciphertext: String,
pub created_by: Option<i64>,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "repo_id", to = "id")]
pub repo: BelongsTo<Option<super::super::repo::repos::Entity>>,
#[sea_orm(belongs_to, from = "space_id", to = "id")]
pub space: BelongsTo<Option<super::super::space::spaces::Entity>>,
#[sea_orm(belongs_to, from = "environment_id", to = "id")]
pub environment: BelongsTo<Option<super::ci_environment::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}