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(Company::Table) .if_not_exists() .col( ColumnDef::new(Company::Id) .integer() .not_null() .auto_increment() .primary_key(), ) .col( ColumnDef::new(Company::Slug) .string() .unique_key() .not_null(), ) .col( ColumnDef::new(Company::Name) .string() .unique_key() .not_null(), ) .to_owned(), ) .await } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .drop_table(Table::drop().table(Company::Table).to_owned()) .await } } /// Learn more at https://docs.rs/sea-query#iden #[derive(Iden)] pub enum Company { Table, Id, Slug, Name, }