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(Flows::Table) .if_not_exists() .col(ColumnDef::new(Flows::Id).string_len(64).not_null().primary_key()) .col(ColumnDef::new(Flows::Name).string().null()) .col(ColumnDef::new(Flows::Yaml).text().null()) .col(ColumnDef::new(Flows::DesignJson).text().null()) .col(ColumnDef::new(Flows::CreatedAt).timestamp().not_null().default(Expr::current_timestamp())) .col(ColumnDef::new(Flows::UpdatedAt).timestamp().not_null().default(Expr::current_timestamp())) .to_owned() ) .await?; Ok(()) } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager.drop_table(Table::drop().table(Flows::Table).to_owned()).await } } #[derive(Iden)] enum Flows { Table, Id, Name, Yaml, DesignJson, CreatedAt, UpdatedAt, }