rave/migration/src/m20231009_181004_create_music_folder.rs

46 lines
1.2 KiB
Rust
Raw Normal View History

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(MusicFolder::Table)
.if_not_exists()
.col(
ColumnDef::new(MusicFolder::Id)
.big_integer()
.not_null()
.primary_key()
.auto_increment()
.unique_key(),
)
.col(
ColumnDef::new(MusicFolder::Name)
.string()
.not_null()
.unique_key(),
)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(MusicFolder::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
pub enum MusicFolder {
Table,
Id,
Name,
}