diff options
Diffstat (limited to 'makima/src/db/repository.rs')
| -rw-r--r-- | makima/src/db/repository.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs index 9a1bf2d..9fc2c84 100644 --- a/makima/src/db/repository.rs +++ b/makima/src/db/repository.rs @@ -2462,6 +2462,7 @@ pub async fn create_contract_for_owner( let autonomous_loop = req.autonomous_loop.unwrap_or(false); let phase_guard = req.phase_guard.unwrap_or(false); let local_only = req.local_only.unwrap_or(false); + let auto_merge_local = req.auto_merge_local.unwrap_or(false); let red_team_enabled = req.red_team_enabled.unwrap_or(false); // Serialize phase_config to JSON @@ -2469,8 +2470,8 @@ pub async fn create_contract_for_owner( sqlx::query_as::<_, Contract>( r#" - INSERT INTO contracts (owner_id, name, description, contract_type, phase, autonomous_loop, phase_guard, local_only, red_team_enabled, red_team_prompt, phase_config) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) + INSERT INTO contracts (owner_id, name, description, contract_type, phase, autonomous_loop, phase_guard, local_only, auto_merge_local, red_team_enabled, red_team_prompt, phase_config) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING * "#, ) @@ -2482,6 +2483,7 @@ pub async fn create_contract_for_owner( .bind(autonomous_loop) .bind(phase_guard) .bind(local_only) + .bind(auto_merge_local) .bind(red_team_enabled) .bind(&req.red_team_prompt) .bind(phase_config_json) @@ -2517,7 +2519,7 @@ pub async fn list_contracts_for_owner( r#" SELECT c.id, c.name, c.description, c.contract_type, c.phase, c.status, - c.supervisor_task_id, c.local_only, c.red_team_enabled, c.version, c.created_at, + c.supervisor_task_id, c.local_only, c.auto_merge_local, c.red_team_enabled, c.version, c.created_at, (SELECT COUNT(*) FROM files WHERE contract_id = c.id) as file_count, (SELECT COUNT(*) FROM tasks WHERE contract_id = c.id) as task_count, (SELECT COUNT(*) FROM contract_repositories WHERE contract_id = c.id) as repository_count @@ -2541,7 +2543,7 @@ pub async fn get_contract_summary_for_owner( r#" SELECT c.id, c.name, c.description, c.contract_type, c.phase, c.status, - c.supervisor_task_id, c.local_only, c.red_team_enabled, c.version, c.created_at, + c.supervisor_task_id, c.local_only, c.auto_merge_local, c.red_team_enabled, c.version, c.created_at, (SELECT COUNT(*) FROM files WHERE contract_id = c.id) as file_count, (SELECT COUNT(*) FROM tasks WHERE contract_id = c.id) as task_count, (SELECT COUNT(*) FROM contract_repositories WHERE contract_id = c.id) as repository_count @@ -2586,14 +2588,15 @@ pub async fn update_contract_for_owner( let autonomous_loop = req.autonomous_loop.unwrap_or(existing.autonomous_loop); let phase_guard = req.phase_guard.unwrap_or(existing.phase_guard); let local_only = req.local_only.unwrap_or(existing.local_only); + let auto_merge_local = req.auto_merge_local.unwrap_or(existing.auto_merge_local); let result = if req.version.is_some() { sqlx::query_as::<_, Contract>( r#" UPDATE contracts SET name = $3, description = $4, phase = $5, status = $6, - supervisor_task_id = $7, autonomous_loop = $8, phase_guard = $9, local_only = $10, version = version + 1, updated_at = NOW() - WHERE id = $1 AND owner_id = $2 AND version = $11 + supervisor_task_id = $7, autonomous_loop = $8, phase_guard = $9, local_only = $10, auto_merge_local = $11, version = version + 1, updated_at = NOW() + WHERE id = $1 AND owner_id = $2 AND version = $12 RETURNING * "#, ) @@ -2607,6 +2610,7 @@ pub async fn update_contract_for_owner( .bind(autonomous_loop) .bind(phase_guard) .bind(local_only) + .bind(auto_merge_local) .bind(req.version.unwrap()) .fetch_optional(pool) .await? @@ -2615,7 +2619,7 @@ pub async fn update_contract_for_owner( r#" UPDATE contracts SET name = $3, description = $4, phase = $5, status = $6, - supervisor_task_id = $7, autonomous_loop = $8, phase_guard = $9, local_only = $10, version = version + 1, updated_at = NOW() + supervisor_task_id = $7, autonomous_loop = $8, phase_guard = $9, local_only = $10, auto_merge_local = $11, version = version + 1, updated_at = NOW() WHERE id = $1 AND owner_id = $2 RETURNING * "#, @@ -2630,6 +2634,7 @@ pub async fn update_contract_for_owner( .bind(autonomous_loop) .bind(phase_guard) .bind(local_only) + .bind(auto_merge_local) .fetch_optional(pool) .await? }; |
