migration/
m20240226_000007_index_initial_seed.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
11 .exec_stmt(
12 Query::insert()
13 .into_table(ChainInfo::Table)
14 .columns([ChainInfo::Id])
15 .values_panic([1.into()])
16 .to_owned(),
17 )
18 .await?;
19
20 manager
22 .exec_stmt(
23 Query::insert()
24 .into_table(NodeInfo::Table)
25 .columns([NodeInfo::Id])
26 .values_panic([1.into()])
27 .to_owned(),
28 )
29 .await
30 }
31
32 async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
33 manager
34 .exec_stmt(
35 Query::delete()
36 .from_table(NodeInfo::Table)
37 .and_where(Expr::col(NodeInfo::Id).eq(1))
38 .to_owned(),
39 )
40 .await?;
41
42 manager
43 .exec_stmt(
44 Query::delete()
45 .from_table(ChainInfo::Table)
46 .and_where(Expr::col(ChainInfo::Id).eq(1))
47 .to_owned(),
48 )
49 .await
50 }
51}
52
53#[derive(DeriveIden)]
54enum ChainInfo {
55 Table,
56 Id,
57}
58
59#[derive(DeriveIden)]
60enum NodeInfo {
61 Table,
62 Id,
63}