feat: add distro table
parent
ecc33f0153
commit
5e1dfd22da
|
@ -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<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod distro;
|
||||
pub mod package;
|
||||
pub mod package_file;
|
||||
pub mod package_group;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue