summaryrefslogtreecommitdiff
path: root/makima/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/db')
-rw-r--r--makima/src/db/repository.rs34
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,