{"record":{"id":"26100eef54e4258f","repo":"Zackriya-Solutions/meetily","slug":"failed-to-delete-existing-transcripts","errorCode":null,"errorMessage":"Failed to delete existing transcripts: {}","messagePattern":"Failed to delete existing transcripts: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/retranscription.rs","lineNumber":440,"sourceCode":"    let segments = create_transcript_segments(&all_transcripts);\n\n    // Save to database\n    let app_state = app\n        .try_state::<AppState>()\n        .ok_or_else(|| anyhow!(\"App state not available\"))?;\n\n    // Wrap delete+insert+update in a transaction to prevent data loss\n    let pool = app_state.db_manager.pool();\n    let mut conn = pool.acquire().await.map_err(|e| anyhow!(\"DB error: {}\", e))?;\n    let mut tx = sqlx::Connection::begin(&mut *conn)\n        .await\n        .map_err(|e| anyhow!(\"Failed to start transaction: {}\", e))?;\n\n    sqlx::query(\"DELETE FROM transcripts WHERE meeting_id = ?\")\n        .bind(&meeting_id)\n        .execute(&mut *tx)\n        .await\n        .map_err(|e| anyhow!(\"Failed to delete existing transcripts: {}\", e))?;\n\n    for segment in &segments {\n        sqlx::query(\n            \"INSERT INTO transcripts (id, meeting_id, transcript, timestamp, audio_start_time, audio_end_time, duration)\n             VALUES (?, ?, ?, ?, ?, ?, ?)\"\n        )\n        .bind(&segment.id)\n        .bind(&meeting_id)\n        .bind(&segment.text)\n        .bind(&segment.timestamp)\n        .bind(segment.audio_start_time)\n        .bind(segment.audio_end_time)\n        .bind(segment.duration)\n        .execute(&mut *tx)\n        .await\n        .map_err(|e| anyhow!(\"Failed to insert transcript: {}\", e))?;\n    }\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/retranscription.rs#L422-L458","documentation":"The DELETE FROM transcripts WHERE meeting_id = ? executed inside the new transaction failed. Because a transaction was already started successfully, the likely causes are schema-level (transcripts table or meeting_id column missing after a skipped migration) or lock/I-O problems on the underlying file, not pool acquisition.","triggerScenarios":"Database created by an older app version whose migrations never produced the transcripts table; a schema where meeting_id was renamed; DB file moved or unmounted between BEGIN and DELETE.","commonSituations":"App upgraded but migrations did not run; user pointed the app at an old data directory; partially interrupted first-run initialization left a half-built schema.","solutions":["Read the inner error: 'no such table: transcripts' means the schema is missing - run app migrations or recreate the DB.","'database is locked' means another writer interfered - retry when idle.","Run PRAGMA integrity_check on the database file to rule out corruption.","Restart the app so the setup/migration path runs again."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the schema exists before starting retranscription\nasync fn transcripts_table_exists(pool: &SqlitePool) -> bool {\n    sqlx::query_scalar::<_, i64>(\n        \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='transcripts'\"\n    ).fetch_one(pool).await.unwrap_or(0) > 0\n}","typeGuard":null,"tryCatchPattern":"// Distinguish schema errors (fix data) from lock errors (retry)\nmatch delete_result {\n    Err(e) if e.to_string().contains(\"no such table\") => return Err(anyhow!(\"schema out of date - run migrations\")),\n    Err(e) if is_busy(&e) => retry_after_idle(),\n    Err(e) => return Err(anyhow!(\"delete failed: {e}\")),\n    Ok(_) => {}\n}","preventionTips":["Run schema migrations at app startup, before any retranscription is possible.","Do not point the app at data directories from incompatible older versions without migrating.","Check DB integrity when unexplained schema errors appear."],"tags":["sqlx","sqlite","delete","schema-mismatch"],"backgroundTag":"sql-delete-failed","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}