Skip to content
Clone
951a522
86 lines 2.5 KB Rust
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 MergeMethod {
#[default]
#[sea_orm(num_value = 0)]
Merge,
#[sea_orm(num_value = 1)]
Squash,
#[sea_orm(num_value = 2)]
Rebase,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "pull_request")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(unique_key = "repo_number")]
pub repo_id: Uuid,
pub issue_id: Option<Uuid>,
#[sea_orm(unique_key = "repo_number")]
pub autoincrement_id: i32,
pub author_id: i64,
pub title: String,
pub body: String,
pub head_branch: String,
pub head_sha: String,
pub head_repo_id: Option<Uuid>,
pub head_label: Option<String>,
pub base_branch: String,
pub base_sha: String,
#[sea_orm(default_value = "false")]
pub is_draft: bool,
#[sea_orm(default_value = "0")]
pub merge_method: MergeMethod,
pub has_merged: bool,
pub merged_commit_sha: Option<String>,
pub squash_commit_sha: Option<String>,
#[sea_orm(default_value = "false")]
pub auto_merge: bool,
pub additions: i32,
pub deletions: i32,
pub files_changed: i32,
pub merger_id: Option<i64>,
pub merged_at: Option<OffsetDateTime>,
pub is_locked: bool,
pub created_at: OffsetDateTime,
pub updated_at: Option<OffsetDateTime>,
pub closed_at: Option<OffsetDateTime>,
#[sea_orm(belongs_to, from = "repo_id", to = "id")]
pub repo: BelongsTo<super::super::repo::repos::Entity>,
#[sea_orm(
belongs_to,
relation_enum = "HeadRepo",
from = "head_repo_id",
to = "id"
)]
pub head_repo: BelongsTo<Option<super::super::repo::repos::Entity>>,
#[sea_orm(belongs_to, from = "issue_id", to = "id")]
pub issue: BelongsTo<Option<super::super::issue::issue_item::Entity>>,
#[sea_orm(belongs_to, relation_enum = "Author", from = "author_id", to = "uid")]
pub author: BelongsTo<super::super::users::user::Entity>,
#[sea_orm(belongs_to, relation_enum = "Merger", from = "merger_id", to = "uid")]
pub merger: BelongsTo<Option<super::super::users::user::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}