feat: Add transcript_source column and type to foundation schema

- Add transcript_source: 'captions' | 'whisper' | null to Job interface in types.ts
- Add idempotent migration for transcript_source column in jobs table
- Update rowToJob to map transcript_source from database
- Update updateJob and resetJob statements to handle transcript_source
- Fix transcriptSource in updateJob function call
- Add transcriptSource: null to all test makeJob helpers

This foundation schema enables transcript source tracking for D2/D5/D6 stories.
Schema migration applies idempotently via addColumnIfMissing utility.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Giancarmine Salucci
2026-08-06 16:17:18 +00:00
co-authored by Claude Haiku 4.5
parent 96ff9cc7fd
commit c8471b787e
6 changed files with 11 additions and 1 deletions
+6 -1
View File
@@ -53,6 +53,7 @@ db.exec(`
try {
addColumnIfMissing('jobs', 'retry_count', 'INTEGER DEFAULT 0');
addColumnIfMissing('jobs', 'next_retry_at', 'TEXT');
addColumnIfMissing('jobs', 'transcript_source', 'TEXT');
} catch (e) {
console.warn('[db] failed to add retry columns:', e);
}
@@ -74,6 +75,7 @@ const stmts = {
error = @error,
retry_count = @retryCount,
next_retry_at = @nextRetryAt,
transcript_source = @transcriptSource,
updated_at = datetime('now')
WHERE id = @id
`),
@@ -87,6 +89,7 @@ const stmts = {
mean_volume = NULL, whisper_job_id = NULL,
output_dir = NULL, segments_json = NULL,
retry_count = 0, next_retry_at = NULL,
transcript_source = NULL,
updated_at = datetime('now')
WHERE id = @id
`),
@@ -116,6 +119,7 @@ function rowToJob(row: Record<string, unknown>): Job {
segmentsJson: row.segments_json as string | null,
error: row.error as string | null,
retryCount: row.retry_count as number | null,
transcriptSource: row.transcript_source as 'captions' | 'whisper' | null,
nextRetryAt: row.next_retry_at as string | null,
createdAt: row.created_at as string,
updatedAt: row.updated_at as string
@@ -152,7 +156,8 @@ export function updateJob(job: Partial<Job> & { id: string }): void {
segmentsJson: merged.segmentsJson,
error: merged.error,
retryCount: merged.retryCount ?? null,
nextRetryAt: merged.nextRetryAt ?? null
nextRetryAt: merged.nextRetryAt ?? null,
transcriptSource: merged.transcriptSource ?? null
});
}
+1
View File
@@ -52,6 +52,7 @@ export interface Job {
error: string | null;
retryCount: number | null;
nextRetryAt: string | null;
transcriptSource: 'captions' | 'whisper' | null;
createdAt: string;
updatedAt: string;
}
+1
View File
@@ -19,6 +19,7 @@ function makeJob(overrides: Partial<Job> = {}): Job {
error: 'transcription timeout',
retryCount: 0,
nextRetryAt: null,
transcriptSource: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...overrides
+1
View File
@@ -21,6 +21,7 @@ function makeJob(overrides: Partial<Job> = {}): Job {
meanVolume: null,
retryCount: null,
nextRetryAt: null,
transcriptSource: null,
...overrides,
};
}
+1
View File
@@ -17,6 +17,7 @@ function makeJob(overrides: Partial<Job> = {}): Job {
error: null,
retryCount: null,
nextRetryAt: null,
transcriptSource: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...overrides
+1
View File
@@ -35,6 +35,7 @@ function makeJob(overrides: Partial<Job> = {}): Job {
error: 'Something failed',
retryCount: 0,
nextRetryAt: null,
transcriptSource: null,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...overrides