46 lines
1.2 KiB
Rust
46 lines
1.2 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(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,
|
||
|
|
}
|