Setup script for restored worktrees (#125)

This commit is contained in:
Solomon
2025-07-11 09:31:33 +01:00
committed by GitHub
parent 960151dbca
commit 3640a61d08
13 changed files with 520 additions and 246 deletions

View File

@@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "UPDATE task_attempts SET setup_completed_at = datetime('now'), updated_at = datetime('now') WHERE id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 1
},
"nullable": []
},
"hash": "1c7b06ba1e112abf6b945a2ff08a0b40ec23f3738c2e7399f067b558cf8d490e"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "UPDATE task_attempts SET worktree_path = $1, worktree_deleted = FALSE, updated_at = datetime('now') WHERE id = $2",
"query": "UPDATE task_attempts SET worktree_path = $1, worktree_deleted = FALSE, setup_completed_at = NULL, updated_at = datetime('now') WHERE id = $2",
"describe": {
"columns": [],
"parameters": {
@@ -8,5 +8,5 @@
},
"nullable": []
},
"hash": "bb11157b104cbf11180b2aa002b74fdba16f0980fc993381a5122b3119348e59"
"hash": "5b902137b11022d2e1a5c4f6a9c83fec1a856c6a710aff831abd2382ede76b43"
}

View File

@@ -1,98 +0,0 @@
{
"db_name": "SQLite",
"query": "\n SELECT ta.id AS \"id!: Uuid\",\n ta.task_id AS \"task_id!: Uuid\",\n ta.worktree_path,\n ta.branch,\n ta.base_branch,\n ta.merge_commit,\n ta.executor,\n ta.pr_url,\n ta.pr_number,\n ta.pr_status,\n ta.pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n ta.worktree_deleted as \"worktree_deleted!: bool\",\n ta.created_at AS \"created_at!: DateTime<Utc>\",\n ta.updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts ta\n JOIN tasks t ON ta.task_id = t.id\n WHERE ta.id = $1\n AND t.id = $2\n AND t.project_id = $3\n ",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "task_id!: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "worktree_path",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "branch",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "base_branch",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "merge_commit",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "executor",
"ordinal": 6,
"type_info": "Text"
},
{
"name": "pr_url",
"ordinal": 7,
"type_info": "Text"
},
{
"name": "pr_number",
"ordinal": 8,
"type_info": "Integer"
},
{
"name": "pr_status",
"ordinal": 9,
"type_info": "Text"
},
{
"name": "pr_merged_at: DateTime<Utc>",
"ordinal": 10,
"type_info": "Datetime"
},
{
"name": "worktree_deleted!: bool",
"ordinal": 11,
"type_info": "Bool"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 12,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 13,
"type_info": "Text"
}
],
"parameters": {
"Right": 3
},
"nullable": [
true,
false,
false,
false,
false,
true,
true,
true,
true,
true,
true,
false,
false,
false
]
},
"hash": "6a0cbee771dc8467a391dbe5acfc0dd23869baaa3030b989cd527d873c26f2f6"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "INSERT INTO task_attempts (id, task_id, worktree_path, branch, base_branch, merge_commit, executor, pr_url, pr_number, pr_status, pr_merged_at, worktree_deleted)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)\n RETURNING id as \"id!: Uuid\", task_id as \"task_id!: Uuid\", worktree_path, branch, base_branch, merge_commit, executor, pr_url, pr_number, pr_status, pr_merged_at as \"pr_merged_at: DateTime<Utc>\", worktree_deleted as \"worktree_deleted!: bool\", created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"",
"query": "INSERT INTO task_attempts (id, task_id, worktree_path, branch, base_branch, merge_commit, executor, pr_url, pr_number, pr_status, pr_merged_at, worktree_deleted, setup_completed_at)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)\n RETURNING id as \"id!: Uuid\", task_id as \"task_id!: Uuid\", worktree_path, branch, base_branch, merge_commit, executor, pr_url, pr_number, pr_status, pr_merged_at as \"pr_merged_at: DateTime<Utc>\", worktree_deleted as \"worktree_deleted!: bool\", setup_completed_at as \"setup_completed_at: DateTime<Utc>\", created_at as \"created_at!: DateTime<Utc>\", updated_at as \"updated_at!: DateTime<Utc>\"",
"describe": {
"columns": [
{
@@ -64,18 +64,23 @@
"type_info": "Bool"
},
{
"name": "created_at!: DateTime<Utc>",
"name": "setup_completed_at: DateTime<Utc>",
"ordinal": 12,
"type_info": "Datetime"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 13,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 13,
"ordinal": 14,
"type_info": "Text"
}
],
"parameters": {
"Right": 12
"Right": 13
},
"nullable": [
true,
@@ -90,9 +95,10 @@
true,
true,
false,
true,
false,
false
]
},
"hash": "e1266b583bd1d164e76fb6a5a906dc229443ec6c437b8eab1c75c625e1cd1166"
"hash": "6e8b860b14decfc2227dc57213f38442943d3fbef5c8418fd6b634c6e0f5e2ea"
}

View File

@@ -1,98 +0,0 @@
{
"db_name": "SQLite",
"query": "SELECT ta.id AS \"id!: Uuid\",\n ta.task_id AS \"task_id!: Uuid\",\n ta.worktree_path,\n ta.branch,\n ta.base_branch,\n ta.merge_commit,\n ta.executor,\n ta.pr_url,\n ta.pr_number,\n ta.pr_status,\n ta.pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n ta.worktree_deleted AS \"worktree_deleted!: bool\",\n ta.created_at AS \"created_at!: DateTime<Utc>\",\n ta.updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts ta\n JOIN tasks t ON ta.task_id = t.id\n WHERE ta.id = $1 AND t.id = $2 AND t.project_id = $3",
"describe": {
"columns": [
{
"name": "id!: Uuid",
"ordinal": 0,
"type_info": "Blob"
},
{
"name": "task_id!: Uuid",
"ordinal": 1,
"type_info": "Blob"
},
{
"name": "worktree_path",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "branch",
"ordinal": 3,
"type_info": "Text"
},
{
"name": "base_branch",
"ordinal": 4,
"type_info": "Text"
},
{
"name": "merge_commit",
"ordinal": 5,
"type_info": "Text"
},
{
"name": "executor",
"ordinal": 6,
"type_info": "Text"
},
{
"name": "pr_url",
"ordinal": 7,
"type_info": "Text"
},
{
"name": "pr_number",
"ordinal": 8,
"type_info": "Integer"
},
{
"name": "pr_status",
"ordinal": 9,
"type_info": "Text"
},
{
"name": "pr_merged_at: DateTime<Utc>",
"ordinal": 10,
"type_info": "Datetime"
},
{
"name": "worktree_deleted!: bool",
"ordinal": 11,
"type_info": "Bool"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 12,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 13,
"type_info": "Text"
}
],
"parameters": {
"Right": 3
},
"nullable": [
true,
false,
false,
false,
false,
true,
true,
true,
true,
true,
true,
false,
false,
false
]
},
"hash": "8a8e1a2a5156b6d0fce8dbfdf4d2fd19501c4246d9b362abc0c489ec0331bf4c"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT ta.id AS \"id!: Uuid\",\n ta.task_id AS \"task_id!: Uuid\",\n ta.worktree_path,\n ta.branch,\n ta.base_branch,\n ta.merge_commit,\n ta.executor,\n ta.pr_url,\n ta.pr_number,\n ta.pr_status,\n ta.pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n ta.worktree_deleted AS \"worktree_deleted!: bool\",\n ta.created_at AS \"created_at!: DateTime<Utc>\",\n ta.updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts ta\n JOIN tasks t ON ta.task_id = t.id\n JOIN projects p ON t.project_id = p.id\n WHERE ta.id = $1 AND t.id = $2 AND p.id = $3",
"query": "SELECT ta.id AS \"id!: Uuid\",\n ta.task_id AS \"task_id!: Uuid\",\n ta.worktree_path,\n ta.branch,\n ta.base_branch,\n ta.merge_commit,\n ta.executor,\n ta.pr_url,\n ta.pr_number,\n ta.pr_status,\n ta.pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n ta.worktree_deleted AS \"worktree_deleted!: bool\",\n ta.setup_completed_at AS \"setup_completed_at: DateTime<Utc>\",\n ta.created_at AS \"created_at!: DateTime<Utc>\",\n ta.updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts ta\n JOIN tasks t ON ta.task_id = t.id\n JOIN projects p ON t.project_id = p.id\n WHERE ta.id = $1 AND t.id = $2 AND p.id = $3",
"describe": {
"columns": [
{
@@ -64,13 +64,18 @@
"type_info": "Bool"
},
{
"name": "created_at!: DateTime<Utc>",
"name": "setup_completed_at: DateTime<Utc>",
"ordinal": 12,
"type_info": "Datetime"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 13,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 13,
"ordinal": 14,
"type_info": "Text"
}
],
@@ -90,9 +95,10 @@
true,
true,
false,
true,
false,
false
]
},
"hash": "9b601854d9adaf1e30ad2d2bed4efc477446de19e61c273bddbc852e8a2eb990"
"hash": "92e8bdbcd80c5ff3db7a35cf79492048803ef305cbdef0d0a1fe5dc881ca8c71"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT id AS \"id!: Uuid\",\n task_id AS \"task_id!: Uuid\",\n worktree_path,\n branch,\n merge_commit,\n base_branch,\n executor,\n pr_url,\n pr_number,\n pr_status,\n pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n worktree_deleted AS \"worktree_deleted!: bool\",\n created_at AS \"created_at!: DateTime<Utc>\",\n updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts\n WHERE id = $1",
"query": "SELECT id AS \"id!: Uuid\",\n task_id AS \"task_id!: Uuid\",\n worktree_path,\n branch,\n merge_commit,\n base_branch,\n executor,\n pr_url,\n pr_number,\n pr_status,\n pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n worktree_deleted AS \"worktree_deleted!: bool\",\n setup_completed_at AS \"setup_completed_at: DateTime<Utc>\",\n created_at AS \"created_at!: DateTime<Utc>\",\n updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts\n WHERE id = $1",
"describe": {
"columns": [
{
@@ -64,13 +64,18 @@
"type_info": "Bool"
},
{
"name": "created_at!: DateTime<Utc>",
"name": "setup_completed_at: DateTime<Utc>",
"ordinal": 12,
"type_info": "Datetime"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 13,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 13,
"ordinal": 14,
"type_info": "Text"
}
],
@@ -90,9 +95,10 @@
true,
true,
false,
true,
false,
false
]
},
"hash": "de6fc34ba5af4479c00e2c03307d430d4b681d6390747a1cbb1e0a02c5918beb"
"hash": "a6d2961718dbc3b1a925e549f49a159c561bef58c105529275f274b27e2eba5b"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT id AS \"id!: Uuid\",\n task_id AS \"task_id!: Uuid\",\n worktree_path,\n branch,\n base_branch,\n merge_commit,\n executor,\n pr_url,\n pr_number,\n pr_status,\n pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n worktree_deleted AS \"worktree_deleted!: bool\",\n created_at AS \"created_at!: DateTime<Utc>\",\n updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts\n WHERE task_id = $1\n ORDER BY created_at DESC",
"query": "SELECT id AS \"id!: Uuid\",\n task_id AS \"task_id!: Uuid\",\n worktree_path,\n branch,\n base_branch,\n merge_commit,\n executor,\n pr_url,\n pr_number,\n pr_status,\n pr_merged_at AS \"pr_merged_at: DateTime<Utc>\",\n worktree_deleted AS \"worktree_deleted!: bool\",\n setup_completed_at AS \"setup_completed_at: DateTime<Utc>\",\n created_at AS \"created_at!: DateTime<Utc>\",\n updated_at AS \"updated_at!: DateTime<Utc>\"\n FROM task_attempts\n WHERE task_id = $1\n ORDER BY created_at DESC",
"describe": {
"columns": [
{
@@ -64,13 +64,18 @@
"type_info": "Bool"
},
{
"name": "created_at!: DateTime<Utc>",
"name": "setup_completed_at: DateTime<Utc>",
"ordinal": 12,
"type_info": "Datetime"
},
{
"name": "created_at!: DateTime<Utc>",
"ordinal": 13,
"type_info": "Text"
},
{
"name": "updated_at!: DateTime<Utc>",
"ordinal": 13,
"ordinal": 14,
"type_info": "Text"
}
],
@@ -90,9 +95,10 @@
true,
true,
false,
true,
false,
false
]
},
"hash": "430f8b4d013ce5bf1bd93242eea086c60e0125d76f9ffa6445addd155ec41059"
"hash": "a9e93d5b09b29faf66e387e4d7596a792d81e75c4d3726e83c2963e8d7c9b56f"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n SELECT ta.id as \"attempt_id!: Uuid\", ta.worktree_path, p.git_repo_path as \"git_repo_path!\"\n FROM task_attempts ta\n JOIN execution_processes ep ON ta.id = ep.task_attempt_id\n JOIN tasks t ON ta.task_id = t.id\n JOIN projects p ON t.project_id = p.id\n WHERE ep.completed_at IS NOT NULL\n AND ta.worktree_deleted = FALSE\n GROUP BY ta.id, ta.worktree_path, p.git_repo_path\n HAVING datetime('now', '-24 hours') > datetime(MAX(ep.completed_at))\n AND ta.id NOT IN (\n SELECT DISTINCT ep2.task_attempt_id\n FROM execution_processes ep2\n WHERE ep2.completed_at IS NULL\n )\n ORDER BY MAX(ep.completed_at) ASC\n ",
"query": "\n SELECT ta.id as \"attempt_id!: Uuid\", ta.worktree_path, p.git_repo_path as \"git_repo_path!\"\n FROM task_attempts ta\n JOIN execution_processes ep ON ta.id = ep.task_attempt_id\n JOIN tasks t ON ta.task_id = t.id\n JOIN projects p ON t.project_id = p.id\n WHERE ep.completed_at IS NOT NULL\n AND ta.worktree_deleted = FALSE\n GROUP BY ta.id, ta.worktree_path, p.git_repo_path\n HAVING datetime('now', '-1 minutes') > datetime(MAX(ep.completed_at))\n AND ta.id NOT IN (\n SELECT DISTINCT ep2.task_attempt_id\n FROM execution_processes ep2\n WHERE ep2.completed_at IS NULL\n )\n ORDER BY MAX(ep.completed_at) ASC\n ",
"describe": {
"columns": [
{
@@ -28,5 +28,5 @@
true
]
},
"hash": "60044d33d4ac014a20f12c53610309814a268b417f25bc6dcde5d3eda13ce0ba"
"hash": "deb5c6ffadf9e67460c37d82520da032bc472ff6d0bd658925b312b18c090f1a"
}