migration/
m20240226_000005_index_create_chain_info.rs1use 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 manager
10 .create_table(
11 Table::create()
12 .table(ChainInfo::Table)
13 .if_not_exists()
14 .col(
15 ColumnDef::new(ChainInfo::Id)
16 .integer()
17 .not_null()
18 .auto_increment()
19 .primary_key(),
20 )
21 .col(
22 ColumnDef::new(ChainInfo::LastIndexedBlock)
23 .integer()
24 .unsigned()
25 .not_null()
26 .default(0),
27 )
28 .col(ColumnDef::new(ChainInfo::TicketPrice).binary_len(12).null())
29 .col(ColumnDef::new(ChainInfo::ChannelsDST).binary_len(32).null())
30 .col(ColumnDef::new(ChainInfo::LedgerDST).binary_len(32).null())
31 .col(ColumnDef::new(ChainInfo::SafeRegistryDST).binary_len(32).null())
32 .col(
33 ColumnDef::new(ChainInfo::NetworkRegistryEnabled)
34 .boolean()
35 .not_null()
36 .default(false),
37 )
38 .col(
39 ColumnDef::new(ChainInfo::ChainChecksum)
40 .binary_len(32)
41 .default(vec![0u8; 32]),
42 )
43 .to_owned(),
44 )
45 .await
46 }
47
48 async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
49 manager
50 .drop_table(Table::drop().table(ChainInfo::Table).to_owned())
51 .await
52 }
53}
54
55#[derive(DeriveIden)]
56enum ChainInfo {
57 Table,
58 Id,
59 LastIndexedBlock,
60 TicketPrice,
61 ChannelsDST,
62 LedgerDST,
63 SafeRegistryDST,
64 NetworkRegistryEnabled,
65 ChainChecksum,
66}