extend recording_playback with an open_id

As noted in schema.sql, this can be used for disambiguation. It also may be
useful in diagnosing data integrity problems.

Also, sneak in a couple minor improvements: better diagnostics in a couple
places, fix to 1->2 upgrade procedure.
This commit is contained in:
Scott Lamb
2018-02-22 21:46:41 -08:00
parent b037c9bdd7
commit bf45ae6011
7 changed files with 31 additions and 15 deletions

View File

@@ -47,8 +47,8 @@ const INSERT_RECORDING_SQL: &'static str = r#"
"#;
const INSERT_RECORDING_PLAYBACK_SQL: &'static str = r#"
insert into recording_playback (composite_id, sample_file_sha1, video_index)
values (:composite_id, :sample_file_sha1, :video_index)
insert into recording_playback (composite_id, open_id, sample_file_sha1, video_index)
values (:composite_id, :open_id, :sample_file_sha1, :video_index)
"#;
const STREAM_MIN_START_SQL: &'static str = r#"
@@ -73,7 +73,7 @@ const STREAM_MAX_START_SQL: &'static str = r#"
"#;
/// Inserts the specified recording (for from `try_flush` only).
pub(crate) fn insert_recording(tx: &rusqlite::Transaction, id: CompositeId,
pub(crate) fn insert_recording(tx: &rusqlite::Transaction, o: &db::Open, id: CompositeId,
r: &db::RecordingToInsert) -> Result<(), Error> {
if r.time.end < r.time.start {
bail!("end time {} must be >= start time {}", r.time.end, r.time.start);
@@ -98,6 +98,7 @@ pub(crate) fn insert_recording(tx: &rusqlite::Transaction, id: CompositeId,
let sha1 = &r.sample_file_sha1[..];
stmt.execute_named(&[
(":composite_id", &id.0),
(":open_id", &o.id),
(":sample_file_sha1", &sha1),
(":video_index", &r.video_index),
])?;