diff --git a/src/migrations/m20240325_000002_add_system_key.rs b/src/migrations/m20240325_000002_add_system_key.rs new file mode 100644 index 00000000..eacfa5d3 --- /dev/null +++ b/src/migrations/m20240325_000002_add_system_key.rs @@ -0,0 +1,44 @@ +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(Application::Table) + .col( + ColumnDef::new(Application::Id) + .integer() + .not_null() + .auto_increment() + .primary_key() + ) + .col(ColumnDef::new(Application::PrivateKey).string().not_null()) + .col(ColumnDef::new(Application::PublicKey).string().not_null()) + .to_owned() + ) + .await?; + + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_table(Table::drop().table(Application::Table).to_owned()) + .await?; + + Ok(()) + } +} + +#[derive(DeriveIden)] +enum Application { + Table, + Id, + PrivateKey, + PublicKey, +} diff --git a/src/migrations/mod.rs b/src/migrations/mod.rs index 5afb5337..97bbc48c 100644 --- a/src/migrations/mod.rs +++ b/src/migrations/mod.rs @@ -8,6 +8,7 @@ mod m20240323_000001_add_user_configs; mod m20240323_000002_add_simple_credentials; mod m20240324_000001_add_addressing; mod m20240325_000001_add_deliveries; +mod m20240325_000002_add_system_key; pub struct Migrator; @@ -23,6 +24,7 @@ impl MigratorTrait for Migrator { Box::new(m20240323_000002_add_simple_credentials::Migration), Box::new(m20240324_000001_add_addressing::Migration), Box::new(m20240325_000001_add_deliveries::Migration), + Box::new(m20240325_000002_add_system_key::Migration), ] } } diff --git a/src/model/application.rs b/src/model/application.rs new file mode 100644 index 00000000..ecb1c42e --- /dev/null +++ b/src/model/application.rs @@ -0,0 +1,16 @@ +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "application")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + + pub private_key: String, + pub public_key: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/model/mod.rs b/src/model/mod.rs index 7dad667d..1fd88ec1 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -10,6 +10,7 @@ pub mod like; pub mod credential; pub mod session; pub mod delivery; +pub mod application; pub mod faker;