From 139be135c2086d725e4f040e744bb25acd436549 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 6 Feb 2026 19:45:45 +0000 Subject: Fix: Directives fixes --- makima/src/db/repository.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'makima/src/db') diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index eeda4a5..cd806f0 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -5191,6 +5191,40 @@ pub async fn update_directive_status( .await } +/// Set the orchestrator contract ID for a directive. +pub async fn set_directive_orchestrator_contract( + pool: &PgPool, + directive_id: Uuid, + contract_id: Uuid, +) -> Result<(), sqlx::Error> { + sqlx::query( + r#" + UPDATE directives SET orchestrator_contract_id = $2, updated_at = NOW() + WHERE id = $1 + "#, + ) + .bind(directive_id) + .bind(contract_id) + .execute(pool) + .await?; + Ok(()) +} + +/// Find a directive by its orchestrator contract ID. +pub async fn get_directive_by_orchestrator_contract_id( + pool: &PgPool, + contract_id: Uuid, +) -> Result, sqlx::Error> { + sqlx::query_as::<_, Directive>( + r#" + SELECT * FROM directives WHERE orchestrator_contract_id = $1 + "#, + ) + .bind(contract_id) + .fetch_optional(pool) + .await +} + /// Archive a directive (soft delete). pub async fn archive_directive_for_owner( pool: &PgPool, -- cgit v1.2.3