migration/
m20240226_000008_node_create_settings.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 manager
10 .create_table(
11 Table::create()
12 .table(GlobalSettings::Table)
13 .if_not_exists()
14 .col(
15 ColumnDef::new(GlobalSettings::Id)
16 .integer()
17 .not_null()
18 .auto_increment()
19 .primary_key(),
20 )
21 .col(
22 ColumnDef::new(GlobalSettings::Key)
23 .string_len(80)
24 .unique_key()
25 .not_null(),
26 )
27 .col(ColumnDef::new(GlobalSettings::Value).binary().not_null())
28 .to_owned(),
29 )
30 .await
31 }
32
33 async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
34 manager
35 .drop_table(Table::drop().table(GlobalSettings::Table).to_owned())
36 .await
37 }
38}
39
40#[derive(DeriveIden)]
41enum GlobalSettings {
42 Table,
43 Id,
44 Key,
45 Value,
46}