diff options
| author | soryu <soryu@soryu.co> | 2026-02-06 19:45:45 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-06 19:45:45 +0000 |
| commit | 139be135c2086d725e4f040e744bb25acd436549 (patch) | |
| tree | 2519f63e1499f8b93a89fde0045fb91d689901d5 /makima/src/db | |
| parent | 25e1275af1b742cc7866fba91152d9a4734a6f94 (diff) | |
| download | soryu-139be135c2086d725e4f040e744bb25acd436549.tar.gz soryu-139be135c2086d725e4f040e744bb25acd436549.zip | |
Fix: Directives fixes
Diffstat (limited to 'makima/src/db')
| -rw-r--r-- | makima/src/db/repository.rs | 34 |
1 files changed, 34 insertions, 0 deletions
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<Option<Directive>, 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, |
