migration/
m20240917_000015_add_minimum_incoming_ticket_win_prob_column.rs

1use sea_orm_migration::prelude::*;
2
3#[derive(DeriveMigrationName)]
4pub struct Migration;
5
6#[async_trait::async_trait]
7impl MigrationTrait for Migration {
8    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
9        // Add a new column to the chain_info table
10        manager
11            .alter_table(
12                Table::alter()
13                    .table(ChainInfo::Table)
14                    .add_column(
15                        ColumnDef::new(ChainInfo::MinIncomingTicketWinProb)
16                            .float()
17                            .not_null()
18                            .default(hopr_internal_types::protocol::DEFAULT_MINIMUM_INCOMING_TICKET_WIN_PROB),
19                    )
20                    .to_owned(),
21            )
22            .await
23    }
24
25    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
26        manager
27            .alter_table(
28                Table::alter()
29                    .table(ChainInfo::Table)
30                    .drop_column(ChainInfo::MinIncomingTicketWinProb)
31                    .to_owned(),
32            )
33            .await
34    }
35}
36
37#[derive(DeriveIden)]
38enum ChainInfo {
39    Table,
40    MinIncomingTicketWinProb,
41}