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, #[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, pub head_label: Option, 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, pub squash_commit_sha: Option, #[sea_orm(default_value = "false")] pub auto_merge: bool, pub additions: i32, pub deletions: i32, pub files_changed: i32, pub merger_id: Option, pub merged_at: Option, pub is_locked: bool, pub created_at: OffsetDateTime, pub updated_at: Option, pub closed_at: Option, #[sea_orm(belongs_to, from = "repo_id", to = "id")] pub repo: BelongsTo, #[sea_orm( belongs_to, relation_enum = "HeadRepo", from = "head_repo_id", to = "id" )] pub head_repo: BelongsTo>, #[sea_orm(belongs_to, from = "issue_id", to = "id")] pub issue: BelongsTo>, #[sea_orm(belongs_to, relation_enum = "Author", from = "author_id", to = "uid")] pub author: BelongsTo, #[sea_orm(belongs_to, relation_enum = "Merger", from = "merger_id", to = "uid")] pub merger: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}