You've already forked seamantic
39 lines
767 B
Rust
39 lines
767 B
Rust
use seamantic::schema::{sqlite_case_insensitive_string, sqlite_rowid_alias};
|
|
|
|
use sea_orm_migration::prelude::*;
|
|
|
|
#[derive(Iden)]
|
|
pub(super) enum Objects {
|
|
Table,
|
|
Id,
|
|
Name,
|
|
}
|
|
|
|
#[derive(DeriveMigrationName)]
|
|
pub(super) struct Migration;
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.create_table(
|
|
Table::create()
|
|
.table(Objects::Table)
|
|
.col(sqlite_rowid_alias(Objects::Id))
|
|
.col(sqlite_case_insensitive_string(Objects::Name))
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(Objects::Table).to_owned())
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|
|
}
|