fitotrack-logger/init.sql
2021-02-24 16:38:49 +01:00

22 lines
860 B
SQL

create table if not exists training(
id uuid primary key default gen_random_uuid(),
owner varchar(255) not null,
filename text not null,
type varchar(255) not null,
description text not null,
moving_time float not null,
stopped_time float not null,
moving_distance float not null,
stopped_distance float not null,
data jsonb not null default '{}'
);
create table if not exists training_data(
training_id uuid not null,
t timestamp with time zone not null,
geog GEOGRAPHY(Point), -- perf issues but don't care enough for geometry->projection->geography conversions
speed float not null,
elevation float not null,
constraint fk_training_id foreign key(training_id) references training(id) on delete cascade
);
create index if not exists idx_training_data_training_id on training_data(training_id);