summaryrefslogtreecommitdiff
path: root/makima/src/db
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-08 12:32:53 +0000
committersoryu <soryu@soryu.co>2026-02-08 12:32:53 +0000
commit657a8e55796c9f0cc6f30937de545ed91f052063 (patch)
tree7944d9e3a4d9e38216fd6358f85d1636d2f75d1e /makima/src/db
parentf0a92073702d614302deff5e83c14ffec3ae6db0 (diff)
downloadsoryu-657a8e55796c9f0cc6f30937de545ed91f052063.tar.gz
soryu-657a8e55796c9f0cc6f30937de545ed91f052063.zip
Fixes for directive chain init
Diffstat (limited to 'makima/src/db')
-rw-r--r--makima/src/db/models.rs7
-rw-r--r--makima/src/db/repository.rs20
2 files changed, 27 insertions, 0 deletions
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<String>,
}
+/// 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<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,