use sea_orm_migration::prelude::*; pub struct Migration; impl MigrationName for Migration { fn name(&self) -> &str { "m20250525_000002_create_ledger_table_book" // Make sure this matches with the file name } } #[async_trait::async_trait] impl MigrationTrait for Migration { // Define how to apply this migration async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .create_table( Table::create() .table(Book::Table) .col( ColumnDef::new(Book::Id) .big_integer() .not_null() .auto_increment() .primary_key(), ) .col(ColumnDef::new(Book::Name).string().not_null()) .col(ColumnDef::new(Book::Uid).big_integer().not_null()) .col(ColumnDef::new(Book::IsDeleted).boolean().default(false).not_null()) .col( ColumnDef::new(Book::CreatedAt) .date_time() .default(Expr::current_timestamp()) .not_null(), ) .col( ColumnDef::new(Book::UpdatedAt) .date_time() .default(Expr::current_timestamp()) .not_null(), ) .to_owned(), ) .await } // Define how to rollback this migration: Drop the Bakery table. async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .drop_table(Table::drop().table(Book::Table).to_owned()) .await } } #[derive(Iden)] pub enum Book { Table, Id, Name, Uid, IsDeleted, CreatedAt, UpdatedAt, }