diff --git a/config/config.toml b/config/config.toml index 295bc8952..3f3f4c490 100644 --- a/config/config.toml +++ b/config/config.toml @@ -25,8 +25,8 @@ db_type = "postgres" db_path = "${base_dir}/mega.db" # database connection url, set to "postgres://mono:mono@mono-pg:5432/mono" if you're using docker -db_url = "postgres://mono:mono@localhost:5432/mono" -#db_url = "postgres://mono:mono@127.0.0.1:5432/mono" +#db_url = "postgres://mono:mono@localhost:5432/mono" +db_url = "postgres://mono:mono@127.0.0.1:5432/mono" # db max connection, setting it to twice the number of CPU cores would be appropriate. max_connection = 16 diff --git a/jupiter/callisto/src/gpg_key.rs b/jupiter/callisto/src/gpg_key.rs index b9ee5c952..be1373802 100644 --- a/jupiter/callisto/src/gpg_key.rs +++ b/jupiter/callisto/src/gpg_key.rs @@ -1,3 +1,5 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14 + use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; @@ -7,7 +9,7 @@ pub struct Model { #[sea_orm(primary_key)] pub id: i64, pub user_id: i64, - #[sea_orm(column_type = "Text", unique)] + #[sea_orm(column_type = "Text")] pub key_id: String, #[sea_orm(column_type = "Text")] pub public_key: String, @@ -31,4 +33,10 @@ pub enum Relation { User, } +impl Related for Entity { + fn to() -> RelationDef { + Relation::User.def() + } +} + impl ActiveModelBehavior for ActiveModel {} diff --git a/jupiter/callisto/src/mod.rs b/jupiter/callisto/src/mod.rs index 99afc44c1..13380b35b 100644 --- a/jupiter/callisto/src/mod.rs +++ b/jupiter/callisto/src/mod.rs @@ -1,6 +1,5 @@ //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14 -pub mod entity_ext; pub mod prelude; pub mod access_token; @@ -44,3 +43,4 @@ pub mod sea_orm_active_enums; pub mod ssh_keys; pub mod user; pub mod vault; +pub mod entity_ext; diff --git a/jupiter/callisto/src/prelude.rs b/jupiter/callisto/src/prelude.rs index d1b7c368a..e25d12b44 100644 --- a/jupiter/callisto/src/prelude.rs +++ b/jupiter/callisto/src/prelude.rs @@ -10,6 +10,7 @@ pub use super::git_pr::Entity as GitPr; pub use super::git_repo::Entity as GitRepo; pub use super::git_tag::Entity as GitTag; pub use super::git_tree::Entity as GitTree; +pub use super::gpg_key::Entity as GpgKey; pub use super::import_refs::Entity as ImportRefs; pub use super::item_assignees::Entity as ItemAssignees; pub use super::item_labels::Entity as ItemLabels; diff --git a/jupiter/callisto/src/user.rs b/jupiter/callisto/src/user.rs index 2f5241f75..cf49322ce 100644 --- a/jupiter/callisto/src/user.rs +++ b/jupiter/callisto/src/user.rs @@ -20,6 +20,15 @@ pub struct Model { } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} +pub enum Relation { + #[sea_orm(has_many = "super::gpg_key::Entity")] + GpgKey, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::GpgKey.def() + } +} impl ActiveModelBehavior for ActiveModel {} diff --git a/jupiter/src/migration/m20250820_102133_gpgkey.rs b/jupiter/src/migration/m20250820_102133_gpgkey.rs index f864c4a3a..ea46c4988 100644 --- a/jupiter/src/migration/m20250820_102133_gpgkey.rs +++ b/jupiter/src/migration/m20250820_102133_gpgkey.rs @@ -1,4 +1,5 @@ use sea_orm_migration::{prelude::*, schema::*}; +use crate::migration::pk_bigint; #[derive(DeriveMigrationName)] pub struct Migration; @@ -12,7 +13,7 @@ impl MigrationTrait for Migration { Table::create() .table(GpgKey::Table) .if_not_exists() - .col(pk_auto(GpgKey::Id)) + .col(pk_bigint(GpgKey::Id)) .col(big_integer(GpgKey::UserId)) .col(text(GpgKey::KeyId)) .col(text(GpgKey::PublicKey))