// 
//	synololog sql database schema
//	
//	Version: 0 
//
//
create table if not exists props (id uuid primary key,name varchar(255) unique,value varchar(255));
create table if not exists devices (id uuid,serial varchar(12));
create table if not exists snapshots (id uuid,device integer,snap_id integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer,field0 integer); 

create table if not exists scripts (id uuid primary key,name varchar(128),description text,elements integer ARRAY default ARRAY[]);

delete from props where name='db.schema.version';
insert into props (id,name,value) values(uuid(),'db.schema.version','0');

