mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-12-03 06:22:32 -05:00
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:
@@ -235,7 +235,7 @@ impl<'a> super::Upgrader for U<'a> {
|
||||
|
||||
-- Insert sub stream (if path is non-empty) using any id.
|
||||
insert into stream (camera_id, sample_file_dir_id, type, record, rtsp_path,
|
||||
retain_bytes, next_recording_id)
|
||||
retain_bytes, flush_if_sec, next_recording_id)
|
||||
select
|
||||
old_camera.id,
|
||||
sample_file_dir.id,
|
||||
@@ -243,7 +243,7 @@ impl<'a> super::Upgrader for U<'a> {
|
||||
0,
|
||||
old_camera.sub_rtsp_path,
|
||||
0,
|
||||
60,
|
||||
90,
|
||||
1
|
||||
from
|
||||
old_camera cross join sample_file_dir
|
||||
|
||||
@@ -148,16 +148,18 @@ impl super::Upgrader for U {
|
||||
alter table recording_playback rename to old_recording_playback;
|
||||
create table recording_playback (
|
||||
composite_id integer primary key references recording (composite_id),
|
||||
open_id integer not null references open (id),
|
||||
sample_file_sha1 blob not null check (length(sample_file_sha1) = 20),
|
||||
video_index blob not null check (length(video_index) > 0)
|
||||
);
|
||||
insert into recording_playback
|
||||
select
|
||||
composite_id,
|
||||
sample_file_sha1,
|
||||
video_index
|
||||
p.composite_id,
|
||||
o.id,
|
||||
p.sample_file_sha1,
|
||||
p.video_index
|
||||
from
|
||||
old_recording_playback;
|
||||
old_recording_playback p cross join open o;
|
||||
drop table old_recording_playback;
|
||||
"#)?;
|
||||
Ok(())
|
||||
|
||||
@@ -136,7 +136,7 @@ fn main() {
|
||||
h.clone().install().unwrap();
|
||||
|
||||
if let Err(e) = { let _a = h.async(); args.arg_command.unwrap().run() } {
|
||||
error!("{}", e);
|
||||
error!("{:?}", e);
|
||||
::std::process::exit(1);
|
||||
}
|
||||
info!("Success.");
|
||||
|
||||
Reference in New Issue
Block a user