diff --git a/server/src/db/entities/distro.rs b/server/src/db/entities/distro.rs new file mode 100644 index 0000000..d819fae --- /dev/null +++ b/server/src/db/entities/distro.rs @@ -0,0 +1,18 @@ +//! `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 = "distro")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub name: String, + pub description: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/server/src/db/entities/mod.rs b/server/src/db/entities/mod.rs index ab8f32a..b38dbb1 100644 --- a/server/src/db/entities/mod.rs +++ b/server/src/db/entities/mod.rs @@ -2,6 +2,7 @@ pub mod prelude; +pub mod distro; pub mod package; pub mod package_file; pub mod package_group; diff --git a/server/src/db/entities/prelude.rs b/server/src/db/entities/prelude.rs index 1a6e503..8ebe873 100644 --- a/server/src/db/entities/prelude.rs +++ b/server/src/db/entities/prelude.rs @@ -1,5 +1,6 @@ //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1 +pub use super::distro::Entity as Distro; pub use super::package::Entity as Package; pub use super::package_file::Entity as PackageFile; pub use super::package_group::Entity as PackageGroup; diff --git a/server/src/db/migrator/m20230730_000001_create_repo_tables.rs b/server/src/db/migrator/m20230730_000001_create_repo_tables.rs index 9d76afc..45ea97c 100644 --- a/server/src/db/migrator/m20230730_000001_create_repo_tables.rs +++ b/server/src/db/migrator/m20230730_000001_create_repo_tables.rs @@ -11,6 +11,27 @@ impl MigrationName for Migration { #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .create_table( + Table::create() + .table(Distro::Table) + .col( + ColumnDef::new(Distro::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col( + ColumnDef::new(Distro::Name) + .string() + .not_null() + .unique_key(), + ) + .col(ColumnDef::new(Distro::Description).string()) + .to_owned(), + ) + .await?; manager .create_table( Table::create() @@ -192,10 +213,21 @@ impl MigrationTrait for Migration { .await?; manager .drop_table(Table::drop().table(Repo::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(Distro::Table).to_owned()) .await } } +#[derive(Iden)] +pub enum Distro { + Table, + Id, + Name, + Description, +} + #[derive(Iden)] pub enum Repo { Table,