diff --git a/src/db/bootstrap.test.ts b/src/db/bootstrap.test.ts index 47d8451..82e3810 100644 --- a/src/db/bootstrap.test.ts +++ b/src/db/bootstrap.test.ts @@ -43,6 +43,7 @@ function getExpectedSchemaMigrations(): Array<{ { version: 16, name: 'room_skill_overrides' }, { version: 17, name: 'scheduled_task_room_role' }, { version: 18, name: 'paired_turn_output_attachments' }, + { version: 19, name: 'turn_progress_text_recovery' }, ]; } diff --git a/src/db/migrations/019_turn-progress-text-recovery.ts b/src/db/migrations/019_turn-progress-text-recovery.ts new file mode 100644 index 0000000..6cf20dc --- /dev/null +++ b/src/db/migrations/019_turn-progress-text-recovery.ts @@ -0,0 +1,35 @@ +import type { Database } from 'bun:sqlite'; + +import { tableHasColumn } from './helpers.js'; +import type { SchemaMigrationDefinition } from './types.js'; + +/** + * Recovery for a migration-version collision introduced by merging + * origin/main into the long-lived deployment branch. + * + * The deployment DB recorded schema version 15 as `reviewer_failure_count` + * (a downstream-only migration), while upstream defines version 15 as + * `turn_progress_text` (migration 015). Because the migration runner tracks + * applied migrations by version number alone, the upstream `turn_progress_text` + * migration is skipped on the live DB and `paired_turns.progress_text` / + * `progress_updated_at` are never created — even though merged runtime code + * (src/db/paired-turns.ts, src/web-dashboard-data.ts) reads and writes them. + * + * This migration re-applies those columns idempotently under a fresh version + * number so the live deployment gets them. It is a no-op on databases where + * migration 015 already ran (fresh installs), thanks to the column guards. + */ +export const TURN_PROGRESS_TEXT_RECOVERY_MIGRATION: SchemaMigrationDefinition = { + version: 19, + name: 'turn_progress_text_recovery', + apply(database: Database) { + if (!tableHasColumn(database, 'paired_turns', 'progress_text')) { + database.exec(`ALTER TABLE paired_turns ADD COLUMN progress_text TEXT`); + } + if (!tableHasColumn(database, 'paired_turns', 'progress_updated_at')) { + database.exec( + `ALTER TABLE paired_turns ADD COLUMN progress_updated_at TEXT`, + ); + } + }, +}; diff --git a/src/db/migrations/index.ts b/src/db/migrations/index.ts index 38f8702..4c67c24 100644 --- a/src/db/migrations/index.ts +++ b/src/db/migrations/index.ts @@ -18,6 +18,7 @@ import { TURN_PROGRESS_TEXT_MIGRATION } from './015_turn-progress-text.js'; import { ROOM_SKILL_OVERRIDES_MIGRATION } from './016_room-skill-overrides.js'; import { SCHEDULED_TASK_ROOM_ROLE_MIGRATION } from './017_scheduled-task-room-role.js'; import { PAIRED_TURN_OUTPUT_ATTACHMENTS_MIGRATION } from './018_paired-turn-output-attachments.js'; +import { TURN_PROGRESS_TEXT_RECOVERY_MIGRATION } from './019_turn-progress-text-recovery.js'; import type { SchemaMigrationArgs, SchemaMigrationDefinition, @@ -44,6 +45,7 @@ const ORDERED_SCHEMA_MIGRATIONS: readonly SchemaMigrationDefinition[] = [ ROOM_SKILL_OVERRIDES_MIGRATION, SCHEDULED_TASK_ROOM_ROLE_MIGRATION, PAIRED_TURN_OUTPUT_ATTACHMENTS_MIGRATION, + TURN_PROGRESS_TEXT_RECOVERY_MIGRATION, ]; function ensureSchemaMigrationsTable(database: Database): void {