From 2184727b3aa59b32d39ff7c8f1ee9555410182e4 Mon Sep 17 00:00:00 2001 From: core Date: Tue, 31 Oct 2023 13:42:49 -0400 Subject: [PATCH] add database field for hosts:update_needed column --- .forgejo/workflows/tfclient.yml | 6 ++ Cargo.lock | 4 +- trifid-api/Cargo.toml | 2 +- trifid-api/trifid_api_entities/Cargo.toml | 2 +- .../trifid_api_entities/src/entity/api_key.rs | 2 +- .../src/entity/api_key_scope.rs | 2 +- .../src/entity/auth_token.rs | 2 +- .../src/entity/firewall_rule.rs | 2 +- .../trifid_api_entities/src/entity/host.rs | 3 +- .../src/entity/host_config_override.rs | 2 +- .../src/entity/host_enrollment_code.rs | 2 +- .../src/entity/host_static_address.rs | 2 +- .../src/entity/keystore_entry.rs | 2 +- .../src/entity/keystore_host.rs | 2 +- .../src/entity/magic_link.rs | 2 +- .../trifid_api_entities/src/entity/mod.rs | 2 +- .../trifid_api_entities/src/entity/network.rs | 2 +- .../src/entity/organization.rs | 2 +- .../trifid_api_entities/src/entity/prelude.rs | 2 +- .../trifid_api_entities/src/entity/role.rs | 2 +- .../src/entity/session_token.rs | 2 +- .../src/entity/signing_ca.rs | 2 +- .../src/entity/totp_authenticator.rs | 2 +- .../trifid_api_entities/src/entity/user.rs | 2 +- trifid-api/trifid_api_migration/Cargo.toml | 2 +- trifid-api/trifid_api_migration/src/lib.rs | 2 + .../m20230427_170037_create_table_hosts.rs | 1 + ...er_table_hosts_add_column_update_needed.rs | 28 +++++++++ .../trifid_api_entities/src/entity/api_key.rs | 41 ------------- .../src/entity/api_key_scope.rs | 32 ---------- .../src/entity/auth_token.rs | 32 ---------- .../src/entity/firewall_rule.rs | 38 ------------ .../src/entity/magic_link.rs | 32 ---------- .../trifid_api_entities/src/entity/mod.rs | 16 ----- .../trifid_api_entities/src/entity/network.rs | 52 ----------------- .../src/entity/organization.rs | 57 ------------------ .../trifid_api_entities/src/entity/prelude.rs | 14 ----- .../trifid_api_entities/src/entity/role.rs | 36 ------------ .../src/entity/session_token.rs | 32 ---------- .../src/entity/signing_ca.rs | 31 ---------- .../src/entity/totp_authenticator.rs | 38 ------------ .../trifid_api_entities/src/entity/user.rs | 58 ------------------- 42 files changed, 63 insertions(+), 534 deletions(-) create mode 100644 trifid-api/trifid_api_migration/src/m20231031_173457_alter_table_hosts_add_column_update_needed.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key_scope.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/auth_token.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/firewall_rule.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/magic_link.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/mod.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/network.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/organization.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/prelude.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/role.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/session_token.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/signing_ca.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/totp_authenticator.rs delete mode 100644 trifid-api/trifid_api_migration/trifid_api_entities/src/entity/user.rs diff --git a/.forgejo/workflows/tfclient.yml b/.forgejo/workflows/tfclient.yml index 2c0e32f..2a05f44 100644 --- a/.forgejo/workflows/tfclient.yml +++ b/.forgejo/workflows/tfclient.yml @@ -29,6 +29,9 @@ jobs: args: --release --bin tfclient - name: Upload binary run: sshpass -p "${{ secrets.TRIFID_DLCDN_PASSWORD }}" rsync --mkpath -e 'ssh -p ${{ secrets.TRIFID_DLCDN_PORT }} -o StrictHostKeyChecking=no' target/release/tfclient ${{ secrets.TRIFID_DLCDN_USER }}@${{ secrets.TRIFID_DLCDN_IP }}:${{ secrets.TRIFID_DLCDN_PATH }}/tfclient/amd64/$GITHUB_SHA/tfclient + + + build_arm64: runs_on: docker-arm64 steps: @@ -57,6 +60,9 @@ jobs: args: --release --bin tfclient --target aarch64-unknown-linux-gnu - name: Upload binary run: sshpass -p "${{ secrets.TRIFID_DLCDN_PASSWORD }}" rsync --mkpath -e 'ssh -p ${{ secrets.TRIFID_DLCDN_PORT }} -o StrictHostKeyChecking=no' target/aarch64-unknown-linux-gnu/release/tfclient ${{ secrets.TRIFID_DLCDN_USER }}@${{ secrets.TRIFID_DLCDN_IP }}:${{ secrets.TRIFID_DLCDN_PATH }}/tfclient/arm64/$GITHUB_SHA/tfclient + + + build_win64: runs_on: docker steps: diff --git a/Cargo.lock b/Cargo.lock index a86fbf4..f1d1b4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1232,7 +1232,7 @@ dependencies = [ [[package]] name = "dnapi-rs" -version = "0.2.0" +version = "0.2.1" dependencies = [ "base64 0.21.5", "base64-serde", @@ -3891,7 +3891,7 @@ dependencies = [ [[package]] name = "trifid-api" -version = "0.2.3" +version = "0.3.0" dependencies = [ "actix-cors", "actix-request-identifier", diff --git a/trifid-api/Cargo.toml b/trifid-api/Cargo.toml index eae1626..739a65a 100644 --- a/trifid-api/Cargo.toml +++ b/trifid-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trifid-api" -version = "0.2.3" +version = "0.3.0" edition = "2021" description = "Pure-rust Defined Networking compatible management server" license = "GPL-3.0-or-later" diff --git a/trifid-api/trifid_api_entities/Cargo.toml b/trifid-api/trifid_api_entities/Cargo.toml index 9bb713d..dd7b667 100644 --- a/trifid-api/trifid_api_entities/Cargo.toml +++ b/trifid-api/trifid_api_entities/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trifid_api_entities" -version = "0.2.0" +version = "0.3.0" edition = "2021" description = "Database entities for trifid-api" license = "GPL-3.0-or-later" diff --git a/trifid-api/trifid_api_entities/src/entity/api_key.rs b/trifid-api/trifid_api_entities/src/entity/api_key.rs index 04aa795..64fbc44 100644 --- a/trifid-api/trifid_api_entities/src/entity/api_key.rs +++ b/trifid-api/trifid_api_entities/src/entity/api_key.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/api_key_scope.rs b/trifid-api/trifid_api_entities/src/entity/api_key_scope.rs index 1deffbc..bf9c094 100644 --- a/trifid-api/trifid_api_entities/src/entity/api_key_scope.rs +++ b/trifid-api/trifid_api_entities/src/entity/api_key_scope.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/auth_token.rs b/trifid-api/trifid_api_entities/src/entity/auth_token.rs index db14039..cba3dbb 100644 --- a/trifid-api/trifid_api_entities/src/entity/auth_token.rs +++ b/trifid-api/trifid_api_entities/src/entity/auth_token.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/firewall_rule.rs b/trifid-api/trifid_api_entities/src/entity/firewall_rule.rs index 6a8c64f..1bbe17e 100644 --- a/trifid-api/trifid_api_entities/src/entity/firewall_rule.rs +++ b/trifid-api/trifid_api_entities/src/entity/firewall_rule.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/host.rs b/trifid-api/trifid_api_entities/src/entity/host.rs index 4313174..785d458 100644 --- a/trifid-api/trifid_api_entities/src/entity/host.rs +++ b/trifid-api/trifid_api_entities/src/entity/host.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; @@ -21,6 +21,7 @@ pub struct Model { pub last_version: i32, pub last_platform: String, pub last_out_of_date: bool, + pub update_needed: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/trifid-api/trifid_api_entities/src/entity/host_config_override.rs b/trifid-api/trifid_api_entities/src/entity/host_config_override.rs index bfe77d2..e278204 100644 --- a/trifid-api/trifid_api_entities/src/entity/host_config_override.rs +++ b/trifid-api/trifid_api_entities/src/entity/host_config_override.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/host_enrollment_code.rs b/trifid-api/trifid_api_entities/src/entity/host_enrollment_code.rs index 8f8c7ab..dbd5119 100644 --- a/trifid-api/trifid_api_entities/src/entity/host_enrollment_code.rs +++ b/trifid-api/trifid_api_entities/src/entity/host_enrollment_code.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/host_static_address.rs b/trifid-api/trifid_api_entities/src/entity/host_static_address.rs index 9b74220..ddba989 100644 --- a/trifid-api/trifid_api_entities/src/entity/host_static_address.rs +++ b/trifid-api/trifid_api_entities/src/entity/host_static_address.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/keystore_entry.rs b/trifid-api/trifid_api_entities/src/entity/keystore_entry.rs index 2087437..caf5e65 100644 --- a/trifid-api/trifid_api_entities/src/entity/keystore_entry.rs +++ b/trifid-api/trifid_api_entities/src/entity/keystore_entry.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/keystore_host.rs b/trifid-api/trifid_api_entities/src/entity/keystore_host.rs index bcac5b8..3910f36 100644 --- a/trifid-api/trifid_api_entities/src/entity/keystore_host.rs +++ b/trifid-api/trifid_api_entities/src/entity/keystore_host.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/magic_link.rs b/trifid-api/trifid_api_entities/src/entity/magic_link.rs index 1707d7e..288cfd4 100644 --- a/trifid-api/trifid_api_entities/src/entity/magic_link.rs +++ b/trifid-api/trifid_api_entities/src/entity/magic_link.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/mod.rs b/trifid-api/trifid_api_entities/src/entity/mod.rs index 334cac8..a5c277d 100644 --- a/trifid-api/trifid_api_entities/src/entity/mod.rs +++ b/trifid-api/trifid_api_entities/src/entity/mod.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 pub mod prelude; diff --git a/trifid-api/trifid_api_entities/src/entity/network.rs b/trifid-api/trifid_api_entities/src/entity/network.rs index c747e2a..9666186 100644 --- a/trifid-api/trifid_api_entities/src/entity/network.rs +++ b/trifid-api/trifid_api_entities/src/entity/network.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/organization.rs b/trifid-api/trifid_api_entities/src/entity/organization.rs index 25d4ff9..7781f8a 100644 --- a/trifid-api/trifid_api_entities/src/entity/organization.rs +++ b/trifid-api/trifid_api_entities/src/entity/organization.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/prelude.rs b/trifid-api/trifid_api_entities/src/entity/prelude.rs index 501f95b..750b641 100644 --- a/trifid-api/trifid_api_entities/src/entity/prelude.rs +++ b/trifid-api/trifid_api_entities/src/entity/prelude.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 pub use super::api_key::Entity as ApiKey; pub use super::api_key_scope::Entity as ApiKeyScope; diff --git a/trifid-api/trifid_api_entities/src/entity/role.rs b/trifid-api/trifid_api_entities/src/entity/role.rs index d664163..df73336 100644 --- a/trifid-api/trifid_api_entities/src/entity/role.rs +++ b/trifid-api/trifid_api_entities/src/entity/role.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/session_token.rs b/trifid-api/trifid_api_entities/src/entity/session_token.rs index a648966..3fbc112 100644 --- a/trifid-api/trifid_api_entities/src/entity/session_token.rs +++ b/trifid-api/trifid_api_entities/src/entity/session_token.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/signing_ca.rs b/trifid-api/trifid_api_entities/src/entity/signing_ca.rs index d0770a9..dc52714 100644 --- a/trifid-api/trifid_api_entities/src/entity/signing_ca.rs +++ b/trifid-api/trifid_api_entities/src/entity/signing_ca.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/totp_authenticator.rs b/trifid-api/trifid_api_entities/src/entity/totp_authenticator.rs index 5437596..f7d6b13 100644 --- a/trifid-api/trifid_api_entities/src/entity/totp_authenticator.rs +++ b/trifid-api/trifid_api_entities/src/entity/totp_authenticator.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_entities/src/entity/user.rs b/trifid-api/trifid_api_entities/src/entity/user.rs index 0d7b61f..bc56c76 100644 --- a/trifid-api/trifid_api_entities/src/entity/user.rs +++ b/trifid-api/trifid_api_entities/src/entity/user.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 use sea_orm::entity::prelude::*; diff --git a/trifid-api/trifid_api_migration/Cargo.toml b/trifid-api/trifid_api_migration/Cargo.toml index 88247f5..91256fc 100644 --- a/trifid-api/trifid_api_migration/Cargo.toml +++ b/trifid-api/trifid_api_migration/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trifid_api_migration" -version = "0.2.0" +version = "0.3.0" edition = "2021" description = "Database migrations for trifid-api" license = "GPL-3.0-or-later" diff --git a/trifid-api/trifid_api_migration/src/lib.rs b/trifid-api/trifid_api_migration/src/lib.rs index 6cc4203..b447286 100644 --- a/trifid-api/trifid_api_migration/src/lib.rs +++ b/trifid-api/trifid_api_migration/src/lib.rs @@ -20,6 +20,7 @@ mod m20230427_171529_create_table_hosts_config_overrides; mod m20230511_120511_create_table_host_enrollment_codes; mod m20230815_225520_create_table_keystore_hosts; mod m20230815_230218_create_table_keystore_entries; +mod m20231031_173457_alter_table_hosts_add_column_update_needed; #[async_trait::async_trait] impl MigratorTrait for Migrator { @@ -43,6 +44,7 @@ impl MigratorTrait for Migrator { Box::new(m20230511_120511_create_table_host_enrollment_codes::Migration), Box::new(m20230815_225520_create_table_keystore_hosts::Migration), Box::new(m20230815_230218_create_table_keystore_entries::Migration), + Box::new(m20231031_173457_alter_table_hosts_add_column_update_needed::Migration), ] } } diff --git a/trifid-api/trifid_api_migration/src/m20230427_170037_create_table_hosts.rs b/trifid-api/trifid_api_migration/src/m20230427_170037_create_table_hosts.rs index b3ce88c..ca6167a 100644 --- a/trifid-api/trifid_api_migration/src/m20230427_170037_create_table_hosts.rs +++ b/trifid-api/trifid_api_migration/src/m20230427_170037_create_table_hosts.rs @@ -88,4 +88,5 @@ pub enum Host { LastVersion, LastPlatform, LastOutOfDate, + UpdateNeeded, // Added in m20231031_173457_alter_table_hosts_add_column_update_needed.rs } diff --git a/trifid-api/trifid_api_migration/src/m20231031_173457_alter_table_hosts_add_column_update_needed.rs b/trifid-api/trifid_api_migration/src/m20231031_173457_alter_table_hosts_add_column_update_needed.rs new file mode 100644 index 0000000..fdc259a --- /dev/null +++ b/trifid-api/trifid_api_migration/src/m20231031_173457_alter_table_hosts_add_column_update_needed.rs @@ -0,0 +1,28 @@ +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 + .alter_table( + Table::alter() + .table(Host::Table) + .add_column(ColumnDef::new(Host::UpdateNeeded).boolean()) + .to_owned() + ).await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(Host::Table) + .drop_column(Host::UpdateNeeded) + .to_owned() + ).await + } +} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key.rs deleted file mode 100644 index 04aa795..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! `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 = "api_key")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - #[sea_orm(unique)] - pub key: String, - pub organization: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_many = "super::api_key_scope::Entity")] - ApiKeyScope, - #[sea_orm( - belongs_to = "super::organization::Entity", - from = "Column::Organization", - to = "super::organization::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Organization, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::ApiKeyScope.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Organization.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key_scope.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key_scope.rs deleted file mode 100644 index 1deffbc..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/api_key_scope.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! `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 = "api_key_scope")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub scope: String, - pub api_key: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::api_key::Entity", - from = "Column::ApiKey", - to = "super::api_key::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - ApiKey, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::ApiKey.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/auth_token.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/auth_token.rs deleted file mode 100644 index db14039..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/auth_token.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! `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 = "auth_token")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub user: String, - pub expires_on: i64, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::user::Entity", - from = "Column::User", - to = "super::user::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - User, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::User.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/firewall_rule.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/firewall_rule.rs deleted file mode 100644 index 6a8c64f..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/firewall_rule.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! `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 = "firewall_rule")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub role: String, - pub protocol: String, - pub description: String, - pub allowed_role_id: Option, - pub port_range_from: i32, - pub port_range_to: i32, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::role::Entity", - from = "Column::AllowedRoleId", - to = "super::role::Column::Id", - on_update = "NoAction", - on_delete = "Cascade" - )] - Role2, - #[sea_orm( - belongs_to = "super::role::Entity", - from = "Column::Role", - to = "super::role::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Role1, -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/magic_link.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/magic_link.rs deleted file mode 100644 index 1707d7e..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/magic_link.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! `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 = "magic_link")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub user: String, - pub expires_on: i64, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::user::Entity", - from = "Column::User", - to = "super::user::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - User, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::User.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/mod.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/mod.rs deleted file mode 100644 index 35ee697..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 - -pub mod prelude; - -pub mod api_key; -pub mod api_key_scope; -pub mod auth_token; -pub mod firewall_rule; -pub mod magic_link; -pub mod network; -pub mod organization; -pub mod role; -pub mod session_token; -pub mod signing_ca; -pub mod totp_authenticator; -pub mod user; diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/network.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/network.rs deleted file mode 100644 index 7d575e6..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/network.rs +++ /dev/null @@ -1,52 +0,0 @@ -//! `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 = "network")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub cidr: String, - #[sea_orm(unique)] - pub organization: String, - #[sea_orm(unique)] - pub signing_ca: String, - pub created_at: i64, - pub name: String, - pub lighthouses_as_relays: bool, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::organization::Entity", - from = "Column::Organization", - to = "super::organization::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Organization, - #[sea_orm( - belongs_to = "super::signing_ca::Entity", - from = "Column::SigningCa", - to = "super::signing_ca::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - SigningCa, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Organization.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::SigningCa.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/organization.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/organization.rs deleted file mode 100644 index 25d4ff9..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/organization.rs +++ /dev/null @@ -1,57 +0,0 @@ -//! `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 = "organization")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub name: String, - #[sea_orm(unique)] - pub owner: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_many = "super::api_key::Entity")] - ApiKey, - #[sea_orm(has_one = "super::network::Entity")] - Network, - #[sea_orm(has_many = "super::role::Entity")] - Role, - #[sea_orm( - belongs_to = "super::user::Entity", - from = "Column::Owner", - to = "super::user::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - User, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::ApiKey.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Network.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Role.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::User.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/prelude.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/prelude.rs deleted file mode 100644 index 93cce0c..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/prelude.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.2 - -pub use super::api_key::Entity as ApiKey; -pub use super::api_key_scope::Entity as ApiKeyScope; -pub use super::auth_token::Entity as AuthToken; -pub use super::firewall_rule::Entity as FirewallRule; -pub use super::magic_link::Entity as MagicLink; -pub use super::network::Entity as Network; -pub use super::organization::Entity as Organization; -pub use super::role::Entity as Role; -pub use super::session_token::Entity as SessionToken; -pub use super::signing_ca::Entity as SigningCa; -pub use super::totp_authenticator::Entity as TotpAuthenticator; -pub use super::user::Entity as User; diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/role.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/role.rs deleted file mode 100644 index b31b820..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/role.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! `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 = "role")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - #[sea_orm(unique)] - pub name: String, - pub description: String, - pub organization: String, - pub created_at: i64, - pub modified_at: i64, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::organization::Entity", - from = "Column::Organization", - to = "super::organization::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - Organization, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Organization.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/session_token.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/session_token.rs deleted file mode 100644 index a648966..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/session_token.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! `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 = "session_token")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub user: String, - pub expires_on: i64, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::user::Entity", - from = "Column::User", - to = "super::user::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - User, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::User.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/signing_ca.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/signing_ca.rs deleted file mode 100644 index d0770a9..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/signing_ca.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! `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 = "signing_ca")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub organization: String, - pub cert: String, - #[sea_orm(unique)] - pub key: String, - pub expires: i64, - #[sea_orm(unique)] - pub nonce: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_one = "super::network::Entity")] - Network, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Network.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/totp_authenticator.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/totp_authenticator.rs deleted file mode 100644 index 5437596..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/totp_authenticator.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! `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 = "totp_authenticator")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - #[sea_orm(unique)] - pub secret: String, - #[sea_orm(unique)] - pub url: String, - pub verified: bool, - pub expires_on: i64, - #[sea_orm(unique)] - pub user: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::user::Entity", - from = "Column::User", - to = "super::user::Column::Id", - on_update = "Cascade", - on_delete = "Cascade" - )] - User, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::User.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/user.rs b/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/user.rs deleted file mode 100644 index 0d7b61f..0000000 --- a/trifid-api/trifid_api_migration/trifid_api_entities/src/entity/user.rs +++ /dev/null @@ -1,58 +0,0 @@ -//! `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 = "user")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - #[sea_orm(unique)] - pub email: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_many = "super::auth_token::Entity")] - AuthToken, - #[sea_orm(has_many = "super::magic_link::Entity")] - MagicLink, - #[sea_orm(has_one = "super::organization::Entity")] - Organization, - #[sea_orm(has_many = "super::session_token::Entity")] - SessionToken, - #[sea_orm(has_one = "super::totp_authenticator::Entity")] - TotpAuthenticator, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AuthToken.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::MagicLink.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Organization.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::SessionToken.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::TotpAuthenticator.def() - } -} - -impl ActiveModelBehavior for ActiveModel {}