feat(transcripts): migration v5 meta — starred, tags, template, language, segments persisted

This commit is contained in:
2026-04-19 16:35:17 +01:00
parent 9378980639
commit e248923f5d
7 changed files with 360 additions and 24 deletions

View File

@@ -115,6 +115,17 @@ const MIGRATIONS: &[(i64, &str, &str)] = &[
(4, "tasks_meta: notes column for persisted free-text", r#"
ALTER TABLE tasks ADD COLUMN notes TEXT NOT NULL DEFAULT ''
"#),
(
5,
"transcripts_meta",
r#"
ALTER TABLE transcripts ADD COLUMN starred INTEGER NOT NULL DEFAULT 0;
ALTER TABLE transcripts ADD COLUMN manual_tags TEXT NOT NULL DEFAULT '';
ALTER TABLE transcripts ADD COLUMN template TEXT NOT NULL DEFAULT '';
ALTER TABLE transcripts ADD COLUMN language TEXT NOT NULL DEFAULT '';
ALTER TABLE transcripts ADD COLUMN segments_json TEXT NOT NULL DEFAULT '';
"#,
),
];
/// Split SQL into individual statements, respecting BEGIN...END trigger blocks.
@@ -215,7 +226,7 @@ mod tests {
.fetch_one(&pool)
.await
.unwrap();
assert_eq!(count, 4);
assert_eq!(count, 5);
sqlx::query("INSERT INTO settings (key, value) VALUES ('test', 'value')")
.execute(&pool)
@@ -237,7 +248,7 @@ mod tests {
.fetch_one(&pool)
.await
.unwrap();
assert_eq!(count, 4);
assert_eq!(count, 5);
}
#[tokio::test]
@@ -268,6 +279,34 @@ mod tests {
}
}
#[tokio::test]
async fn migration_transcripts_meta_adds_columns() {
// Task 2.5 — verify starred / manual_tags / template / language /
// segments_json are all present on the transcripts table after
// migrations run. All five are added by v5.
let pool = SqlitePoolOptions::new()
.max_connections(1)
.connect("sqlite::memory:")
.await
.expect("pool");
run_migrations(&pool).await.expect("migrate");
let info = sqlx::query("PRAGMA table_info(transcripts)")
.fetch_all(&pool)
.await
.unwrap();
let names: Vec<String> = info
.iter()
.map(|r| r.get::<String, _>("name"))
.collect();
for col in ["starred", "manual_tags", "template", "language", "segments_json"] {
assert!(
names.contains(&col.to_string()),
"transcripts must have {col}; got {names:?}"
);
}
}
#[tokio::test]
async fn test_parent_task_id_cascade_delete() {
let pool = SqlitePoolOptions::new()