relay-agent-migration 0.1.0

Migrations for the Relay Mail Agent
Documentation
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveIden)]
enum Users {
    Table,
    Id,
    Ed25519,
    X25519,
    CreatedAt,
    ExpiresAt,
}

#[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(Users::Table)
                    .if_not_exists()
                    .col(string(Users::Id).not_null().primary_key())
                    .col(string(Users::Ed25519).not_null())
                    .col(string(Users::X25519).not_null())
                    .col(timestamp(Users::CreatedAt).not_null())
                    .col(timestamp_null(Users::ExpiresAt))
                    .to_owned(),
            )
            .await
    }

    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .drop_table(Table::drop().table(Users::Table).to_owned())
            .await
    }
}