migration 0.2.2

SeaORM Migration for ARPA
Documentation
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(LootRandomnessTask::Table)
                    .if_not_exists()
                    .col(
                        ColumnDef::new(LootRandomnessTask::Id)
                            .integer()
                            .not_null()
                            .primary_key(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::RequestId)
                            .blob(BlobSize::Medium)
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::SubscriptionId)
                            .big_unsigned()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::GroupIndex)
                            .unsigned()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::RequestType)
                            .tiny_unsigned()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::Params)
                            .blob(BlobSize::Medium)
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::Requester)
                            .text()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::Seed)
                            .blob(BlobSize::Medium)
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::RequestConfirmations)
                            .unsigned()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::CallbackGasLimit)
                            .unsigned()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::CallbackMaxGasPrice)
                            .blob(BlobSize::Medium)
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::AssignmentBlockHeight)
                            .big_unsigned()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::State)
                            .tiny_unsigned()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::CreateAt)
                            .date_time()
                            .not_null(),
                    )
                    .col(
                        ColumnDef::new(LootRandomnessTask::UpdateAt)
                            .date_time()
                            .not_null(),
                    )
                    .to_owned(),
            )
            .await
    }

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

#[derive(Iden)]
pub enum LootRandomnessTask {
    Table,
    Id,
    RequestId,
    SubscriptionId,
    GroupIndex,
    RequestType,
    Params,
    Requester,
    Seed,
    RequestConfirmations,
    CallbackGasLimit,
    CallbackMaxGasPrice,
    AssignmentBlockHeight,
    State,
    CreateAt,
    UpdateAt,
}