migration/
m20240810_000014_index_extend_chain_info_with_pre_checksum_block.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::PreviousIndexedBlockPrioToChecksumUpdate)
16                            .integer()
17                            .unsigned()
18                            .not_null()
19                            .default(0),
20                    )
21                    .to_owned(),
22            )
23            .await
24    }
25
26    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
27        manager
28            .alter_table(
29                Table::alter()
30                    .table(ChainInfo::Table)
31                    .drop_column(ChainInfo::PreviousIndexedBlockPrioToChecksumUpdate)
32                    .to_owned(),
33            )
34            .await
35    }
36}
37
38#[derive(DeriveIden)]
39enum ChainInfo {
40    Table,
41    PreviousIndexedBlockPrioToChecksumUpdate,
42}