From 5959e2a3ee74e136f2a5ef1837f83e323bd7b5e3 Mon Sep 17 00:00:00 2001 From: AidCheng Date: Wed, 27 Aug 2025 10:34:35 +0100 Subject: [PATCH 1/2] [jupiter]UPDATE:sync entity structure with migrations Signed-off-by: AidCheng --- jupiter/callisto/src/gpg_key.rs | 12 ++++++++++-- jupiter/callisto/src/mod.rs | 1 - jupiter/callisto/src/prelude.rs | 1 + jupiter/callisto/src/user.rs | 11 ++++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/jupiter/callisto/src/gpg_key.rs b/jupiter/callisto/src/gpg_key.rs index b9ee5c952..32852e914 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}; @@ -5,9 +7,9 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "gpg_key")] pub struct Model { #[sea_orm(primary_key)] - pub id: i64, + pub id: i32, 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..c3cacaa9d 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; 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 {} From 95c37ccf306e172aebf928c7293d961e7a4fd7bf Mon Sep 17 00:00:00 2001 From: AidCheng Date: Wed, 27 Aug 2025 10:55:52 +0100 Subject: [PATCH 2/2] [jupiter]UPDATE: attach entity_ext & change gpg id to i64 Signed-off-by: AidCheng --- config/config.toml | 4 ++-- jupiter/callisto/src/gpg_key.rs | 2 +- jupiter/callisto/src/mod.rs | 1 + jupiter/src/migration/m20250820_102133_gpgkey.rs | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) 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 32852e914..be1373802 100644 --- a/jupiter/callisto/src/gpg_key.rs +++ b/jupiter/callisto/src/gpg_key.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "gpg_key")] pub struct Model { #[sea_orm(primary_key)] - pub id: i32, + pub id: i64, pub user_id: i64, #[sea_orm(column_type = "Text")] pub key_id: String, diff --git a/jupiter/callisto/src/mod.rs b/jupiter/callisto/src/mod.rs index c3cacaa9d..13380b35b 100644 --- a/jupiter/callisto/src/mod.rs +++ b/jupiter/callisto/src/mod.rs @@ -43,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/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))