62 lines
2.0 KiB
Rust
62 lines
2.0 KiB
Rust
use sea_orm_migration::prelude::*;
|
|
|
|
#[derive(DeriveMigrationName)]
|
|
pub struct Migration;
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.create_table(
|
|
Table::create()
|
|
.table(Agents::Table)
|
|
.if_not_exists()
|
|
.col(ColumnDef::new(Agents::Id).uuid().not_null().primary_key())
|
|
.col(ColumnDef::new(Agents::Name).string().not_null())
|
|
.col(ColumnDef::new(Agents::IpAddress).string())
|
|
.col(ColumnDef::new(Agents::Version).string())
|
|
.col(ColumnDef::new(Agents::State).string().not_null())
|
|
.col(ColumnDef::new(Agents::DeploymentMode).string())
|
|
.col(ColumnDef::new(Agents::LastSeenAt).timestamp_with_time_zone())
|
|
.col(ColumnDef::new(Agents::Capabilities).json())
|
|
.col(ColumnDef::new(Agents::PublicKeyHash).string())
|
|
.col(ColumnDef::new(Agents::Labels).json())
|
|
.col(
|
|
ColumnDef::new(Agents::CreatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null(),
|
|
)
|
|
.col(
|
|
ColumnDef::new(Agents::UpdatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null(),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(Agents::Table).to_owned())
|
|
.await
|
|
}
|
|
}
|
|
|
|
#[derive(DeriveIden)]
|
|
enum Agents {
|
|
Table,
|
|
Id,
|
|
Name,
|
|
IpAddress,
|
|
Version,
|
|
State,
|
|
DeploymentMode,
|
|
LastSeenAt,
|
|
Capabilities,
|
|
PublicKeyHash,
|
|
Labels,
|
|
CreatedAt,
|
|
UpdatedAt,
|
|
}
|