From bed910dcaed66d6a7d669305546a60bba31da47a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 7 Apr 2026 15:59:28 -0400 Subject: [PATCH] Consolidate archived_git_worktrees schema into CREATE TABLE Remove the old commit_hash and restored columns that were never shipped, and fold the staged_commit_hash, unstaged_commit_hash, and original_commit_hash columns directly into the CREATE TABLE statement instead of adding them via ALTER TABLE migrations. Also fix a bug in the INSERT where unstaged_commit_hash was bound twice (once where commit_hash used to go). --- crates/agent_ui/src/thread_metadata_store.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/crates/agent_ui/src/thread_metadata_store.rs b/crates/agent_ui/src/thread_metadata_store.rs index 4766e00424a0c9d007c09637468da5e9fd11fe94..ed7931c7dcc2d1afc3e672ce460c2f58c1a8a55a 100644 --- a/crates/agent_ui/src/thread_metadata_store.rs +++ b/crates/agent_ui/src/thread_metadata_store.rs @@ -736,8 +736,9 @@ impl Domain for ThreadMetadataDb { worktree_path TEXT NOT NULL, main_repo_path TEXT NOT NULL, branch_name TEXT, - commit_hash TEXT NOT NULL, - restored INTEGER NOT NULL DEFAULT 0 + staged_commit_hash TEXT, + unstaged_commit_hash TEXT, + original_commit_hash TEXT ) STRICT; CREATE TABLE IF NOT EXISTS thread_archived_worktrees( @@ -746,15 +747,6 @@ impl Domain for ThreadMetadataDb { PRIMARY KEY (session_id, archived_worktree_id) ) STRICT; ), - sql!( - ALTER TABLE archived_git_worktrees ADD COLUMN staged_commit_hash TEXT; - ALTER TABLE archived_git_worktrees ADD COLUMN unstaged_commit_hash TEXT; - UPDATE archived_git_worktrees SET staged_commit_hash = commit_hash, unstaged_commit_hash = commit_hash WHERE staged_commit_hash IS NULL; - ), - sql!( - ALTER TABLE archived_git_worktrees ADD COLUMN original_commit_hash TEXT; - UPDATE archived_git_worktrees SET original_commit_hash = commit_hash WHERE original_commit_hash IS NULL; - ), ]; } @@ -856,14 +848,13 @@ impl ThreadMetadataDb { self.write(move |conn| { let mut stmt = Statement::prepare( conn, - "INSERT INTO archived_git_worktrees(worktree_path, main_repo_path, branch_name, commit_hash, staged_commit_hash, unstaged_commit_hash, original_commit_hash) \ - VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7) \ + "INSERT INTO archived_git_worktrees(worktree_path, main_repo_path, branch_name, staged_commit_hash, unstaged_commit_hash, original_commit_hash) \ + VALUES (?1, ?2, ?3, ?4, ?5, ?6) \ RETURNING id", )?; let mut i = stmt.bind(&worktree_path, 1)?; i = stmt.bind(&main_repo_path, i)?; i = stmt.bind(&branch_name, i)?; - i = stmt.bind(&unstaged_commit_hash, i)?; i = stmt.bind(&staged_commit_hash, i)?; i = stmt.bind(&unstaged_commit_hash, i)?; stmt.bind(&original_commit_hash, i)?;