summaryrefslogtreecommitdiff
path: root/makima/src/db/repository.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/db/repository.rs')
-rw-r--r--makima/src/db/repository.rs20
1 files changed, 20 insertions, 0 deletions
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<Option<Directive>, 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,