Initial thoughts around API, DB layer.

This commit is contained in:
2019-02-15 00:00:20 -06:00
commit 0d2efe4bcc
16 changed files with 314 additions and 0 deletions

View File

@ -0,0 +1,5 @@
-- DOWN script for initial-schema (20190214122514)
drop table if exists "values";
drop table if exists "measures";
drop table if exists "api_tokens";
drop table if exists "users";

View File

@ -0,0 +1,38 @@
-- UP script for initial-schema (20190214122514)
create extension if not exists "uuid-ossp";
create table "users" (
id uuid default uuid_generate_v4() primary key,
display_name varchar not null,
email varchar not null,
hashedpwd varchar not null
);
create table "api_tokens" (
id uuid default uuid_generate_v4() primary key,
user_id uuid not null references users (id) on delete cascade on update cascade,
name varchar not null,
expires timestamp with time zone default null,
hashedToken varchar not null
);
create table "measures" (
id uuid default uuid_generate_v4() primary key,
user_id uuid not null references users (id) on delete cascade on update cascade,
slug varchar not null,
name varchar not null,
description varchar not null default '',
domain_source varchar default null ,
domain_units varchar not null default '',
range_source varchar default null,
range_units varchar not null default '',
analysis varchar[] not null default '{}'
);
create table "values" (
id uuid default uuid_generate_v4() primary key,
measure_id uuid not null references measures (id) on delete cascade on update cascade,
value integer not null,
"timestamp" timestamp not null default current_timestamp,
ext_data jsonb not null default '{}'::json
);