feat: added repo mirrors migration
This commit is contained in:
parent
f761e3b36d
commit
cbb04a40e0
9 changed files with 135 additions and 1 deletions
|
|
@ -9,3 +9,4 @@ pub mod package_group;
|
|||
pub mod package_license;
|
||||
pub mod package_related;
|
||||
pub mod repo;
|
||||
pub mod repo_mirror;
|
||||
|
|
|
|||
|
|
@ -7,3 +7,4 @@ pub use super::package_group::Entity as PackageGroup;
|
|||
pub use super::package_license::Entity as PackageLicense;
|
||||
pub use super::package_related::Entity as PackageRelated;
|
||||
pub use super::repo::Entity as Repo;
|
||||
pub use super::repo_mirror::Entity as RepoMirror;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ pub struct Model {
|
|||
#[sea_orm(unique)]
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub r#type: crate::RepoType,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
@ -26,6 +27,8 @@ pub enum Relation {
|
|||
Distro,
|
||||
#[sea_orm(has_many = "super::package::Entity")]
|
||||
Package,
|
||||
#[sea_orm(has_many = "super::repo_mirror::Entity")]
|
||||
RepoMirror,
|
||||
}
|
||||
|
||||
impl Related<super::distro::Entity> for Entity {
|
||||
|
|
@ -40,4 +43,10 @@ impl Related<super::package::Entity> for Entity {
|
|||
}
|
||||
}
|
||||
|
||||
impl Related<super::repo_mirror::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::RepoMirror.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
|
|
|||
33
entity/src/entity/repo_mirror.rs
Normal file
33
entity/src/entity/repo_mirror.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "repo_mirror")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub repo_id: i32,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::repo::Entity",
|
||||
from = "Column::RepoId",
|
||||
to = "super::repo::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Repo,
|
||||
}
|
||||
|
||||
impl Related<super::repo::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Repo.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
|
@ -35,3 +35,12 @@ pub enum PackageState {
|
|||
#[sea_orm(num_value = 2)]
|
||||
PendingDeletion,
|
||||
}
|
||||
|
||||
#[derive(EnumIter, DeriveActiveEnum, Deserialize, Serialize, PartialEq, Eq, Clone, Debug)]
|
||||
#[sea_orm(rs_type = "i32", db_type = "Integer")]
|
||||
pub enum RepoType {
|
||||
#[sea_orm(num_value = 0)]
|
||||
Regular,
|
||||
#[sea_orm(num_value = 1)]
|
||||
FullMirror,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue