test and fix signal_camera upgrade problems

- after 3->4 upgrade, it left the foreign key referring to the
  nonexistent old_camera table. Likely no one who did the upgrade
  has ever inserted anything into this table, so no one's noticed.
- 6->7 upgrade dropped tables in the wrong order, so if there was
  anything in the signal_camera table, the upgrade would fail.
This commit is contained in:
Scott Lamb
2021-10-26 14:00:18 -07:00
parent 363fc8a267
commit 08cef6e790
3 changed files with 28 additions and 12 deletions

View File

@@ -27,13 +27,6 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
color text
);
create table signal_camera (
signal_id integer references signal (id),
camera_id integer references camera (id),
type integer not null,
primary key (signal_id, camera_id)
) without rowid;
create table signal_change (
time_90k integer primary key,
changes blob not null
@@ -69,6 +62,13 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
from
old_camera;
create table signal_camera (
signal_id integer references signal (id),
camera_id integer references camera (id),
type integer not null,
primary key (signal_id, camera_id)
) without rowid;
alter table stream rename to old_stream;
create table stream (
id integer primary key,