sea-orm/examples/loco_seaography/migration/src/m20231103_114510_notes.rs
Billy Chan 9fd5523d65
Examples: Loco x Seaography (#2270)
* Examples: Loco x Seaography

* fmt

* Edit
2024-06-26 14:50:00 +08:00

34 lines
817 B
Rust

use sea_orm_migration::{prelude::*, schema::*};
#[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_auto(Notes::Table)
.col(pk_auto(Notes::Id))
.col(string_null(Notes::Title))
.col(string_null(Notes::Content))
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Notes::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
pub enum Notes {
Table,
Id,
Title,
Content,
}