tweak and document version 3->4 upgrade

This commit is contained in:
Scott Lamb 2019-06-20 16:03:59 -07:00
parent 4f25412c3f
commit eaf6608597
3 changed files with 21 additions and 7 deletions

View File

@ -332,7 +332,7 @@ create table user (
-- Permissions available for newly created tokens or when authenticating via
-- unix_uid above. A serialized "Permissions" protobuf.
permissions blob
permissions blob not null default X''
);
-- A single session, whether for browser or robot use.
@ -398,7 +398,7 @@ create table user_session (
use_count not null default 0,
-- Permissions associated with this token; a serialized "Permissions" protobuf.
permissions blob
permissions blob not null default X''
) without rowid;
create index user_session_uid on user_session (user_id);
@ -481,7 +481,7 @@ create table signal_change (
-- delta: 1 1 196 (must be non-negative)
-- states: 1 1 2
-- varint: \x01 \x01 \x01 \x01 \xc4 \x01 \x02
changes blob
changes blob not null
);
insert into version (id, unix_time, notes)

View File

@ -58,13 +58,18 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
primary key (signal_id, camera_id)
) without rowid;
create table signal_state (
create table signal_change (
time_90k integer primary key,
changes blob
changes blob not null
);
alter table user add column permissions blob;
alter table user_session add column permissions blob;
alter table user add column permissions blob not null default X'';
alter table user_session add column permissions blob not null default X'';
-- Set permissions to "view_video" on existing users and sessions to preserve their
-- behavior. Newly created users won't have prepopulated permissions like this.
update user set permissions = X'0801';
update user_session set permissions = X'0801';
"#)?;
Ok(())
}

View File

@ -222,3 +222,12 @@ Version 3 adds over version 1:
separate uuid which has to be reserved in advance.
* additional timestamp fields which may be useful in diagnosing/correcting
time jumps/inconsistencies.
### Version 3 to version 4
This upgrade affects only the SQLite database. Version 4 adds over version 3:
* permissions for users and sessions. Existing users will have only the
`view_video` permission, matching their previous behavior.
* the `signals` schema, used to store status of signals such as camera
motion detection, security system zones, etc.