HB, OTA etc
This commit is contained in:
20
db/migrations/V2__telemetry_data.sql
Normal file
20
db/migrations/V2__telemetry_data.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE telemetry_data (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
|
||||
device_id BIGINT NOT NULL,
|
||||
ts BIGINT NOT NULL,
|
||||
|
||||
metric VARCHAR(32) NOT NULL,
|
||||
source VARCHAR(64) NOT NULL,
|
||||
|
||||
value DOUBLE NOT NULL,
|
||||
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
INDEX idx_device_metric_ts (device_id, metric, ts),
|
||||
INDEX idx_ts (ts),
|
||||
|
||||
FOREIGN KEY (device_id) REFERENCES devices(id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_processed ON telemetry(processed);
|
||||
2
db/migrations/V3__telemetry_processed_index.sql
Normal file
2
db/migrations/V3__telemetry_processed_index.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
CREATE INDEX idx_telemetry_processed_id
|
||||
ON telemetry (processed, id);
|
||||
16
db/migrations/V4__telemetry_units.sql
Normal file
16
db/migrations/V4__telemetry_units.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
alter TABLE telemetry
|
||||
add defective boolean default false,
|
||||
add defective_reason varchar(64);
|
||||
|
||||
alter TABLE telemetry_data ADD
|
||||
unit varchar (16);
|
||||
|
||||
create table units (
|
||||
unit varchar(16) not null,
|
||||
target_unit varchar(16) not null,
|
||||
multiplier double not null,
|
||||
primary key (unit)
|
||||
);
|
||||
|
||||
insert into units (unit, target_unit, multiplier)
|
||||
values ('c_x100', 'c', 0.01);
|
||||
24
db/migrations/V5__firmware_updates.sql
Normal file
24
db/migrations/V5__firmware_updates.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
create table firmware (
|
||||
id int not null auto_increment,
|
||||
device_id bigint not null,
|
||||
version int not null,
|
||||
path varchar(4096) not null,
|
||||
sha256 char(64),
|
||||
size int,
|
||||
uploaded_at timestamp not null default current_timestamp,
|
||||
primary key (id),
|
||||
foreign key (device_id) references devices(id),
|
||||
|
||||
unique(device_id, version)
|
||||
);
|
||||
|
||||
create table firmware_updates (
|
||||
id int not null auto_increment,
|
||||
firmware_id int not null,
|
||||
status varchar(32) not null, -- pending / sent / applied / failed
|
||||
requested_at timestamp not null default current_timestamp,
|
||||
applied_at timestamp null,
|
||||
|
||||
primary key (id),
|
||||
foreign key (firmware_id) references firmware(id)
|
||||
);
|
||||
Reference in New Issue
Block a user