mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-26 20:38:43 -05:00
move open_id from recording_playback to recording
I want to be able to use it in etags without having to do a full scan of the recording_playback in advance, which would greatly increase time to first byte. I probably will even use it in urls to ensure the segments they point to are stable. I haven't actually done this yet - it will wait until I implement serving unflushed recordings - but I want to get the schema set up properly.
This commit is contained in:
@@ -167,6 +167,7 @@ impl<'a> super::Upgrader for U<'a> {
|
||||
create table recording (
|
||||
composite_id integer primary key,
|
||||
stream_id integer not null references stream (id),
|
||||
open_id integer not null,
|
||||
run_offset integer not null,
|
||||
flags integer not null,
|
||||
sample_file_bytes integer not null check (sample_file_bytes > 0),
|
||||
@@ -183,6 +184,7 @@ impl<'a> super::Upgrader for U<'a> {
|
||||
create index recording_cover on recording (
|
||||
stream_id,
|
||||
start_time_90k,
|
||||
open_id,
|
||||
duration_90k,
|
||||
video_samples,
|
||||
video_sync_samples,
|
||||
@@ -252,19 +254,20 @@ impl<'a> super::Upgrader for U<'a> {
|
||||
|
||||
insert into recording
|
||||
select
|
||||
composite_id,
|
||||
camera_id,
|
||||
run_offset,
|
||||
flags,
|
||||
sample_file_bytes,
|
||||
start_time_90k,
|
||||
duration_90k,
|
||||
local_time_delta_90k,
|
||||
video_samples,
|
||||
video_sync_samples,
|
||||
video_sample_entry_id
|
||||
r.composite_id,
|
||||
r.camera_id,
|
||||
o.open_id,
|
||||
r.run_offset,
|
||||
r.flags,
|
||||
r.sample_file_bytes,
|
||||
r.start_time_90k,
|
||||
r.duration_90k,
|
||||
r.local_time_delta_90k,
|
||||
r.video_samples,
|
||||
r.video_sync_samples,
|
||||
r.video_sample_entry_id
|
||||
from
|
||||
old_recording;
|
||||
old_recording r cross join open o;
|
||||
"#)?;
|
||||
|
||||
fix_video_sample_entry(tx)?;
|
||||
|
||||
@@ -148,18 +148,16 @@ 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
|
||||
p.composite_id,
|
||||
o.id,
|
||||
p.sample_file_sha1,
|
||||
p.video_index
|
||||
composite_id,
|
||||
sample_file_sha1,
|
||||
video_index
|
||||
from
|
||||
old_recording_playback p cross join open o;
|
||||
old_recording_playback;
|
||||
drop table old_recording_playback;
|
||||
"#)?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user