From 657a8e55796c9f0cc6f30937de545ed91f052063 Mon Sep 17 00:00:00 2001 From: soryu Date: Sun, 8 Feb 2026 12:32:53 +0000 Subject: Fixes for directive chain init --- makima/src/db/models.rs | 7 +++++++ makima/src/db/repository.rs | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'makima/src/db') diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index eff2df0..6045c7d 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -2824,6 +2824,13 @@ pub struct CreateDirectiveRequest { pub base_branch: Option, } +/// Request to submit a chain plan for a directive. +#[derive(Debug, Clone, Deserialize, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct SubmitPlanRequest { + pub plan: String, +} + /// Request to update an existing directive. #[derive(Debug, Clone, Deserialize, ToSchema)] #[serde(rename_all = "camelCase")] diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index 177aed3..ed56fff 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -5279,6 +5279,26 @@ pub async fn set_directive_current_chain( .await } +/// Increment the chain_generation_count on a directive (without setting current_chain_id). +pub async fn increment_chain_generation_count( + pool: &PgPool, + directive_id: Uuid, +) -> Result, sqlx::Error> { + sqlx::query_as::<_, Directive>( + r#" + UPDATE directives + SET chain_generation_count = chain_generation_count + 1, + version = version + 1, + updated_at = NOW() + WHERE id = $1 + RETURNING * + "#, + ) + .bind(directive_id) + .fetch_optional(pool) + .await +} + /// Create a new directive chain. pub async fn create_directive_chain( pool: &PgPool, -- cgit v1.2.3