finish adding keystore v2 stuffs
This commit is contained in:
parent
e901f63bb9
commit
3dadd40bba
|
@ -0,0 +1,41 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "keystore_entry")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: String,
|
||||
pub host: String,
|
||||
pub counter: i32,
|
||||
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
|
||||
pub signing_key: Vec<u8>,
|
||||
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
|
||||
pub client_signing_key: Vec<u8>,
|
||||
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
|
||||
pub client_dh_key: Vec<u8>,
|
||||
pub config: String,
|
||||
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
|
||||
pub certificate: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::host::Entity",
|
||||
from = "Column::Host",
|
||||
to = "super::host::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
Host,
|
||||
}
|
||||
|
||||
impl Related<super::host::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Host.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
|
@ -0,0 +1,16 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "keystore_host")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: String,
|
||||
pub counter: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
|
@ -0,0 +1,39 @@
|
|||
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(KeystoreHost::Table)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreHost::Id)
|
||||
.string()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreHost::Counter)
|
||||
.integer()
|
||||
.not_null()
|
||||
)
|
||||
.to_owned()
|
||||
).await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(KeystoreHost::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
enum KeystoreHost {
|
||||
Table,
|
||||
Id,
|
||||
Counter,
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
use crate::m20230427_170037_create_table_hosts::Host;
|
||||
|
||||
#[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(KeystoreEntry::Table)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::Id)
|
||||
.string()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::Host)
|
||||
.string()
|
||||
.not_null()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::Counter)
|
||||
.integer()
|
||||
.not_null()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::SigningKey)
|
||||
.binary()
|
||||
.not_null()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::ClientSigningKey)
|
||||
.binary()
|
||||
.not_null()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::ClientDHKey)
|
||||
.binary()
|
||||
.not_null()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::Config)
|
||||
.string()
|
||||
.not_null()
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(KeystoreEntry::Certificate)
|
||||
.binary()
|
||||
.not_null()
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(KeystoreEntry::Table, KeystoreEntry::Host)
|
||||
.to(Host::Table, Host::Id)
|
||||
)
|
||||
.index(
|
||||
Index::create()
|
||||
.name("idx-keystore-entry-host-counter-unique")
|
||||
.table(KeystoreEntry::Table)
|
||||
.col(KeystoreEntry::Host)
|
||||
.col(KeystoreEntry::Counter)
|
||||
.unique()
|
||||
)
|
||||
.to_owned()
|
||||
).await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(KeystoreEntry::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
enum KeystoreEntry {
|
||||
Table,
|
||||
Id,
|
||||
Host,
|
||||
Counter,
|
||||
SigningKey,
|
||||
ClientSigningKey,
|
||||
ClientDHKey,
|
||||
Config,
|
||||
Certificate
|
||||
}
|
Loading…
Reference in New Issue