Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .agents/scripts/supervisor/database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#
# Functions for database schema management, migrations, and backups


#######################################
# Backup supervisor database before destructive operations (t162, t188)
# Delegates to shared backup_sqlite_db() from shared-constants.sh.
Expand Down Expand Up @@ -573,6 +572,15 @@ CONTEST_SQL
log_success "Added last_main_sha column to tasks (t1029)"
fi

# Migrate: add prompt_repeat_done column to tasks (t1097)
local has_prompt_repeat_done
has_prompt_repeat_done=$(db "$SUPERVISOR_DB" "SELECT count(*) FROM pragma_table_info('tasks') WHERE name='prompt_repeat_done';" 2>/dev/null || echo "0")
if [[ "$has_prompt_repeat_done" -eq 0 ]]; then
log_info "Migrating tasks table: adding prompt_repeat_done column (t1097)..."
db "$SUPERVISOR_DB" "ALTER TABLE tasks ADD COLUMN prompt_repeat_done INTEGER NOT NULL DEFAULT 0;" 2>/dev/null || true
log_success "Added prompt_repeat_done column to tasks (t1097)"
fi

# Ensure WAL mode for existing databases created before t135.3
local current_mode
current_mode=$(db "$SUPERVISOR_DB" "PRAGMA journal_mode;" 2>/dev/null || echo "")
Expand Down Expand Up @@ -615,6 +623,7 @@ CREATE TABLE IF NOT EXISTS tasks (
triage_result TEXT,
escalation_depth INTEGER NOT NULL DEFAULT 0,
max_escalation INTEGER NOT NULL DEFAULT 2,
prompt_repeat_done INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
started_at TEXT,
completed_at TEXT,
Expand Down
Loading
Loading