feat(server): add more package metadata tables
This commit is contained in:
parent
731ad37a2a
commit
aef2c823e5
15 changed files with 466 additions and 8 deletions
|
|
@ -3,5 +3,10 @@
|
|||
pub mod prelude;
|
||||
|
||||
pub mod package;
|
||||
pub mod package_conflicts;
|
||||
pub mod package_depends;
|
||||
pub mod package_group;
|
||||
pub mod package_license;
|
||||
pub mod package_provides;
|
||||
pub mod package_replaces;
|
||||
pub mod repo;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,18 @@ pub struct Model {
|
|||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::package_conflicts::Entity")]
|
||||
PackageConflicts,
|
||||
#[sea_orm(has_many = "super::package_depends::Entity")]
|
||||
PackageDepends,
|
||||
#[sea_orm(has_many = "super::package_group::Entity")]
|
||||
PackageGroup,
|
||||
#[sea_orm(has_many = "super::package_license::Entity")]
|
||||
PackageLicense,
|
||||
#[sea_orm(has_many = "super::package_provides::Entity")]
|
||||
PackageProvides,
|
||||
#[sea_orm(has_many = "super::package_replaces::Entity")]
|
||||
PackageReplaces,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::repo::Entity",
|
||||
from = "Column::RepoId",
|
||||
|
|
@ -38,12 +48,42 @@ pub enum Relation {
|
|||
Repo,
|
||||
}
|
||||
|
||||
impl Related<super::package_conflicts::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::PackageConflicts.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::package_depends::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::PackageDepends.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::package_group::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::PackageGroup.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::package_license::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::PackageLicense.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::package_provides::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::PackageProvides.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::package_replaces::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::PackageReplaces.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::repo::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Repo.def()
|
||||
|
|
|
|||
33
server/src/db/entities/package_conflicts.rs
Normal file
33
server/src/db/entities/package_conflicts.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 = "package_conflicts")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub package_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::package::Entity",
|
||||
from = "Column::PackageId",
|
||||
to = "super::package::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Package,
|
||||
}
|
||||
|
||||
impl Related<super::package::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Package.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
35
server/src/db/entities/package_depends.rs
Normal file
35
server/src/db/entities/package_depends.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//! `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 = "package_depends")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub package_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub r#type: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::package::Entity",
|
||||
from = "Column::PackageId",
|
||||
to = "super::package::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Package,
|
||||
}
|
||||
|
||||
impl Related<super::package::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Package.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
33
server/src/db/entities/package_group.rs
Normal file
33
server/src/db/entities/package_group.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 = "package_group")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub package_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::package::Entity",
|
||||
from = "Column::PackageId",
|
||||
to = "super::package::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Package,
|
||||
}
|
||||
|
||||
impl Related<super::package::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Package.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
33
server/src/db/entities/package_provides.rs
Normal file
33
server/src/db/entities/package_provides.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 = "package_provides")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub package_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::package::Entity",
|
||||
from = "Column::PackageId",
|
||||
to = "super::package::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Package,
|
||||
}
|
||||
|
||||
impl Related<super::package::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Package.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
33
server/src/db/entities/package_replaces.rs
Normal file
33
server/src/db/entities/package_replaces.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 = "package_replaces")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub package_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::package::Entity",
|
||||
from = "Column::PackageId",
|
||||
to = "super::package::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Package,
|
||||
}
|
||||
|
||||
impl Related<super::package::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Package.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1
|
||||
|
||||
pub use super::package::Entity as Package;
|
||||
pub use super::package_conflicts::Entity as PackageConflicts;
|
||||
pub use super::package_depends::Entity as PackageDepends;
|
||||
pub use super::package_group::Entity as PackageGroup;
|
||||
pub use super::package_license::Entity as PackageLicense;
|
||||
pub use super::package_provides::Entity as PackageProvides;
|
||||
pub use super::package_replaces::Entity as PackageReplaces;
|
||||
pub use super::repo::Entity as Repo;
|
||||
|
|
|
|||
|
|
@ -90,7 +90,152 @@ impl MigrationTrait for Migration {
|
|||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(PackageGroup::Table)
|
||||
.col(ColumnDef::new(PackageGroup::PackageId).integer().not_null())
|
||||
.col(
|
||||
ColumnDef::new(PackageGroup::Value)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(PackageGroup::PackageId)
|
||||
.col(PackageGroup::Value),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk-package_group-package_id")
|
||||
.from(PackageGroup::Table, PackageGroup::PackageId)
|
||||
.to(Package::Table, Package::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(PackageReplaces::Table)
|
||||
.col(
|
||||
ColumnDef::new(PackageReplaces::PackageId)
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PackageReplaces::Value)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(PackageReplaces::PackageId)
|
||||
.col(PackageReplaces::Value),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk-package_replaces-package_id")
|
||||
.from(PackageReplaces::Table, PackageReplaces::PackageId)
|
||||
.to(Package::Table, Package::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(PackageConflicts::Table)
|
||||
.col(
|
||||
ColumnDef::new(PackageConflicts::PackageId)
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PackageConflicts::Value)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(PackageConflicts::PackageId)
|
||||
.col(PackageConflicts::Value),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk-package_conflicts-package_id")
|
||||
.from(PackageConflicts::Table, PackageConflicts::PackageId)
|
||||
.to(Package::Table, Package::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(PackageProvides::Table)
|
||||
.col(
|
||||
ColumnDef::new(PackageProvides::PackageId)
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PackageProvides::Value)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(PackageProvides::PackageId)
|
||||
.col(PackageProvides::Value),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk-package_provides-package_id")
|
||||
.from(PackageProvides::Table, PackageProvides::PackageId)
|
||||
.to(Package::Table, Package::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(PackageDepends::Table)
|
||||
.col(
|
||||
ColumnDef::new(PackageDepends::PackageId)
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(PackageDepends::Type).integer().not_null())
|
||||
.col(
|
||||
ColumnDef::new(PackageDepends::Value)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(PackageDepends::PackageId)
|
||||
.col(PackageDepends::Type)
|
||||
.col(PackageDepends::Value),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk-package_depends-package_id")
|
||||
.from(PackageDepends::Table, PackageDepends::PackageId)
|
||||
.to(Package::Table, Package::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Define how to rollback this migration: Drop the Bakery table.
|
||||
|
|
@ -98,6 +243,21 @@ impl MigrationTrait for Migration {
|
|||
manager
|
||||
.drop_table(Table::drop().table(PackageLicense::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(PackageGroup::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(PackageReplaces::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(PackageConflicts::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(PackageProvides::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(PackageDepends::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(Package::Table).to_owned())
|
||||
.await?;
|
||||
|
|
@ -141,3 +301,39 @@ pub enum PackageLicense {
|
|||
PackageId,
|
||||
Value,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum PackageGroup {
|
||||
Table,
|
||||
PackageId,
|
||||
Value,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum PackageReplaces {
|
||||
Table,
|
||||
PackageId,
|
||||
Value,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum PackageConflicts {
|
||||
Table,
|
||||
PackageId,
|
||||
Value,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum PackageProvides {
|
||||
Table,
|
||||
PackageId,
|
||||
Value,
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum PackageDepends {
|
||||
Table,
|
||||
PackageId,
|
||||
Type,
|
||||
Value,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue