#![allow(clippy::enum_variant_names)]
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveIden)]
pub enum Inbox {
Table,
Id,
InboxId,
UserId,
CreatedAt,
}
#[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(Inbox::Table)
.if_not_exists()
.col(uuid(Inbox::Id).not_null().primary_key())
.col(ColumnDef::new(Inbox::InboxId).string_len(64))
.col(ColumnDef::new(Inbox::UserId).string_len(64).not_null())
.col(ColumnDef::new(Inbox::CreatedAt).timestamp().not_null())
.index(
Index::create()
.unique()
.name("idx_inbox_user_inbox")
.table(Inbox::Table)
.col(Inbox::UserId)
.col(Inbox::InboxId),
)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Inbox::Table).to_owned())
.await
}
}