Alisa/crates/migration/src/m20240709_095319_create_license_group.rs

39 lines
1.1 KiB
Rust

use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(LicenseGroup::Table)
.if_not_exists()
.col(
ColumnDef::new(LicenseGroup::Id)
.uuid()
.not_null()
.primary_key()
.extra("DEFAULT gen_random_uuid()"),
)
.col(ColumnDef::new(LicenseGroup::Name).string().not_null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(LicenseGroup::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
enum LicenseGroup {
Table,
Id,
Name,
}